I need to test a bunch of code that extensively uses a mysql database (both
selects and inserts), and I want to do it without actually writing to the
database.. Instead of commenting out all of the $db->query($insert_query)
statements and echoing $insert_query, I thought I'd make the following
object:
class TestDB {
var $realDB;
function TestDB(&$o)
{
echo $o;
$this->realDB = &$o;
echo $this->realDB;
}
function query($q)
{
echo $q;
}
function getOne($q)
{
return $this->realDB->getOne($q);
}
function getRow($q)
{
return $this->realDB->getRow($q);
}
function &resetDB()
{
return $this->realDB;
}
}
Then, in my code, I instantiate it like so:
$tmp = new TestDB($db);
$db = &$tmp;
But this doesn't work, and I can't figure out why. When I try to call
$db->getRow($q) I was getting an error that said that I couldn't call a
member function of a non-object. I've changed things around now, and I'm
just not getting anything. Any idea why I would get the non-object error?
Thanks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php