Forums / Developer / Why dont this work??
Claus Jensen
Friday 12 December 2003 7:00:55 am
Hello there,Im trying to do a query to the ezdb inside a php-script im making, to import some objects from a text file. Here is the code:
include_once( "lib/ezutils/classes/ezdebug.php" ); //eZDebug::setHandleType( EZ_HANDLE_FROM_PHP ); include_once( "lib/ezutils/classes/ezmodule.php" ); eZModule::setGlobalPathList( array( "kernel" ) ); include_once( 'lib/ezutils/classes/ezexecution.php' ); include_once( 'kernel/classes/ezcontentobjecttreenode.php' ); eZDebug::setHandleType( EZ_HANDLE_TO_PHP ); eZDebug::setLogFileEnabled( false ); eZINI::setIsCacheEnabled( false ); eZExecution::addCleanupHandler( 'eZDBCleanup' );eZExecution::addFatalErrorHandler( 'eZFatalError' );
//get db-connection $db =& eZDB::instance(); ... //this is the line its refering to, line 84 $rows = $db->arrayQuery( "SELECT * FROM ezcontentobject_tree WHERE parentnode_id = $parentnodeid" );...etc
and the output when I run it is: <b>Fatal error</b>: Call to a member function on a non-object in <b>/data/Exponential/3.2-1/met_imp_final.php</b> on line <b>84</b><br /> Fatal error: Exponential did not finish it's requestThe execution of Exponential was abruptly ended.
Its like $db is not an object?!?!? I dont get it. Does anybody know why this is happening?
Thanks for replys,claÜs
Eirik Alfstad Johansen
Sunday 14 December 2003 10:45:19 am
Hi Claus,
I might be way off here, but shouldn't the ampersand be before the equal sign when you create an instance of the eZDB class?
Like this:
$db &= eZDB::instance();
Sincerely,
Eirik JohansenNetmaking AS
http://www.netmaking.no/
Sincerely, Eirik Alfstad Johansen http://www.netmaking.no/
Sunday 14 December 2003 11:51:15 pm
Morning,Its working in Exponential so I guess maybe you can do both with the same result. I cant get why this is not working.
Anybody else? Here it is again: //get db-connection $db =& eZDB::instance(); ... //this is the line its refering to, line 84 $rows = $db->arrayQuery( "SELECT * FROM ezcontentobject_tree WHERE parentnode_id = $parentnodeid" );...etc
If somebody has a clue, please let me know.claÜs
Monday 15 December 2003 3:24:07 am
Hi again Claus,
Shouldn't you also include the /lib/ezdb/classes/ezdb.php which includes the class definition for eZDB class? Also, you might want to print out the $db var to see what it actually contains.