• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI Database class is broken. It's dead... out of nowhere!

#1
[eluser]Fabdrol[/eluser]
Code:
A PHP Error was encountered

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename: database/DB_active_rec.php

Line Number: 453

Ever seen this? I haven't at least. How it occured? I was coding an app, everything worked great..

Until I uploaded a file (using my app) and the front-end of the app got fubar. Strangely, the back-end still works great!

Weird innit?

Any suggestions?

#2
[eluser]Fabdrol[/eluser]
And as sudden as it appeared, it was gone.

#3
[eluser]Fabdrol[/eluser]
Guess I found the problem: somehow the code composes a Query out of two different querys..
this is the case:
Code:
function a($ex) {
foreach($ex as $e) {
// $ex = array('perma1', 'perma2', 'perma3');
$uid = $this->b($e);

if($uid != false) {
$this->db->where('group !=', $uid);
}
}

// do some more stuff based on the generated where clauses.
}

function b($p) {
$this->db->select('uid');
$this->db->where('perma', $p);

// do db stuff

return $uid // from db
}

In this example the code generates a combined query out of function a & b, like this:
SELECT uid FROM groups WHERE perma = 'perma1' AND group != 'fjdka89343kasd23234dahth';

That's not good.. is it a bug? oh, and I get the following error now:
Code:
A Database Error Occurred

Error Number: 1054

Unknown column 'group' in 'where clause'

SELECT `uid` FROM (`groups`) WHERE `group` != '3aed4079ce471782187e3baea9708327' AND `perma` = 'mr'

In the error, you see the "`group` != '3aed4079ce471782187e3baea9708327'" part. that shouldn't be in that query, but in anothr query.. is it a CI bug? or did I do something stupid?

#4
[eluser]CactusCoder[/eluser]
Did you ever get this resolved?

I've run into the same problem and have been unable to figure out the cause :-(

Losing the last few hairs I have left...

#5
[eluser]CactusCoder[/eluser]
Mystery solved...

I use iScaffold to generate the CRUD for my tables and it turns on the AR cache for the list and search pages and flushes the cache at the end of both functions, but it doesn't turn it off.

The solution is to call both stop_cache() and flush_cache() when you're done with a particular set of queries.

Hope this helps someone :-)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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