![]() |
Returns result from DB even though it's empty! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Returns result from DB even though it's empty! (/showthread.php?tid=22159) |
Returns result from DB even though it's empty! - El Forum - 08-31-2009 [eluser]felixk[/eluser] Controller: Code: function index() Viewer: Code: <?php if(empty($albums)): echo "Empty! :S"; ?> Returns result from DB even though it's empty! - El Forum - 08-31-2009 [eluser]felixk[/eluser] If I do a var_dump($albums) the result is: Quote:object(CI_DB_mysql_result)#18 (7) { ["conn_id"]=> resource(30) of type (mysql link persistent) ["result_id"]=> resource(40) of type (mysql result) ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(0) ["row_data"]=> NULL } Returns result from DB even though it's empty! - El Forum - 08-31-2009 [eluser]bretticus[/eluser] Don't check empty. In the manual the examples show checking num_rows(). So try checking $albums->num_rows(). Returns result from DB even though it's empty! - El Forum - 08-31-2009 [eluser]felixk[/eluser] Thanks! It's weird that the exact same code, but in other controllers and views files worked as I wanted. |