Skip to content

Instantly share code, notes, and snippets.

@andyhawthorne
Created August 9, 2013 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyhawthorne/6197218 to your computer and use it in GitHub Desktop.
Save andyhawthorne/6197218 to your computer and use it in GitHub Desktop.
<?php
class Tasks_Model extends CI_Model
{
public function __construct()
{
parent:: __construct();
}
public function get_tasks($month)
{
$sql = "SELECT DAY(due) As day, due, title FROM tasks_list WHERE MONTH(due) = " . $month;
$q = $this->db->query($sql);
$num = $q->num_rows();
if($num > 0)
{
foreach($q->result() as $row)
{
$data[] = $row;
}
foreach($data as $d)
{
$out[$d->day] = (int)$d->day;
$out[$d->day] = "http://tasks.dev/welcome/show/" . date('Y/m/d', strtotime($d->due));
}
return $out;
}
else
{
return 0;
}
}
public function day_tasks($day)
{
$sql = "SELECT * FROM tasks_list WHERE due = '" . $day . "'";
$q = $this->db->query($sql);
if($q->num_rows() > 0)
{
foreach($q->result() as $row)
{
$data[] = $row;
}
return $data;
}
else
{
return 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment