CodeIgniter Forums
no result for simple queries - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: no result for simple queries (/showthread.php?tid=2700)



no result for simple queries - El Forum - 08-20-2007

[eluser]xwero[/eluser]
I didn't know if this is a bug or a design decision so i posted it here.

i was playing with the mysql functions and i discovered
Code:
$query = $this->db->query('select DAYOFWEEK('.$year.'-'.$month.'-'.$day.') as nr');
$row = $query->row();
echo $query->num_rows();
echo $row->nr;
nr doesn't display anything eventhough the num_rows method displays 1.

Is there a workaround to display this sort of query results or do i have to use the native php functions for this?


no result for simple queries - El Forum - 08-20-2007

[eluser]xwero[/eluser]
ok i solved the problem.

Code:
$query = $this->db->query('select DAYOFWEEK('.$year.'-'.$month.'-'.$day.') as nr');

had to be

Code:
$query = $this->db->query('select DAYOFWEEK("'.$year.'-'.$month.'-'.$day.'") as nr');

what a rookie mistake.