• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Num_rows() returns error message

#1
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?
Reply

#2
(10-19-2017, 08: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.
Reply

#3
(10-19-2017, 09:43 AM)Narf Wrote:
(10-19-2017, 08: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).
Reply

#4
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.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.