Welcome Guest, Not a member yet? Register   Sign In
[Help] Call to a member function result_array() on a non-object /path/to/models/db.php on line XXX
#1

[eluser]Unknown[/eluser]
I receive a lot of said error since early this year.

Example:
Code:
....
$query = $this->db->query($sql);
$result = $query->result_array(); <-- error here!
....

From php error log, I found the above code being requested multiple times per second, which I believe causing delay on Mysql to produce the object. I tried to simulate multiple request/second on my localhost but no such error exist. However, it does happen to my shared-hosting server (few sites, diff servers).

Hence, can someone advice wither below code should work?

Example:
Code:
....
$query = $this->db->query($sql);
  while (!is_object($query)) //Wait until $query become an object
    sleep(1);
$result = $query->result_array();
....

Can I wait $query become an object first, BEFORE continue with the the next line?

Thanks a lot.
#2

[eluser]InsiteFX[/eluser]
If pconnect is set to true it can sometimes cause problems.

The only other thing I could think of may be the MySQL or
PHP.ini time_out values set to high these should be set to
around 10 seconds or lower.

but try below:

Code:
$db['default']['pconnect'] = FALSE;

Enjoy
InsiteFX
#3

[eluser]Unknown[/eluser]
thanks InsiteFX,

Will try and update this thread soon.




Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB