For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > September 2005 > Weird DB_DataObject problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Weird DB_DataObject problem
Joseph Szobody

2005-09-29, 6:57 pm

Folks,

I just installed DB_DataObject on my server, and moved over some code that I
had working on another server. I am having a very strange problem where my
find() returns a number of results, but when I go to fetch there is nothing
there. If I turn on debug and do a get(), I see a serialized array that
contains data from the database, but when I try to echo a value or even do a
print_r() on the DO I get an empty object.

For instance, here is one quick example:

DB_DataObject::debugLevel(5);
$dbo = DB_DataObject::factory("tbl_admin");
$num = $dbo->find(); // Find everything
echo "Results found: $num <br>";
while($dbo->fetch()) {
print_r($dbo);
}

Now, there are three rows in the "tbl_admin" table admin table, and the
above correctly echoes "Results found: 3". But as soon as I do $dbo->fetch,
I get this:

dbo_tbl_admin: FETCH: No data returned from FIND (eg. N is 0)

If I add any whereAdds() before find, it correctly finds the right records,
and again displays the correct "Results found:". So it connects to the
database fine, and the query works, but when fetch() goes to fetch it it
gives me an error that there is no data.

Any help would be greatly appreciated.

Joseph
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com