CodeIgniter Forums
[SOLVED] Num_rows() returns error message - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: [SOLVED] Num_rows() returns error message (/showthread.php?tid=69206)



[SOLVED] Num_rows() returns error message - Wouter60 - 10-19-2017

My application is using the sqlsrv database driver.

In many queries, the $query->num_rows() function throws an error:

Code:
fatal error: call to a member function num_rows() on boolean

Even if I use the $this->db->list_tables() function, I get this terrible error, but I'm sure may database contains several tables.

Any tips how to solve this?


RE: Num_rows() returns error message - Narf - 10-19-2017

(10-19-2017, 07:33 AM)Wouter60 Wrote: fatal error: call to a member function num_rows() on boolean

That means that $query is a TRUE/FALSE and not an object. Likely FALSE due to query failure.


RE: Num_rows() returns error message - Wouter60 - 10-19-2017

(10-19-2017, 08:43 AM)Narf Wrote:
(10-19-2017, 07:33 AM)Wouter60 Wrote: fatal error: call to a member function num_rows() on boolean

That means that $query is a TRUE/FALSE and not an object. Likely FALSE due to query failure.

I know, but how can $this->db->list_tables() cause this error?
In MySQL, I've never seen this error. There, I can check for $query->num_rows() == 0); This doesn't seem to work in MSSQL (Windows Server).


RE: Num_rows() returns error message - InsiteFX - 10-19-2017

Try doing a var_dump or print_r of the $query to see what is happening,
Or echo it to the screen you should see where the error is.


RE: Num_rows() returns error message - Wouter60 - 10-19-2017

Solved it!
I autoloaded a model, that referred to a non-existing table. After I disabled that, the error no longer occurred.