Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Num_rows() returns error message
#1

(This post was last modified: 10-19-2017, 09:05 AM by Wouter60.)

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

(This post was last modified: 10-19-2017, 08:43 AM by Narf. Edit Reason: formatting )

(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.
Reply
#3

(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).
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 CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 10-19-2017, 09:06 AM by Wouter60.)

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




Theme © iAndrew 2016 - Forum software by © MyBB