Why dont this work??

Author Message

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/ezpublish/3.2-1/met_imp_final.php</b> on line <b>84</b><br />
Fatal error: eZ publish did not finish it's request
The execution of eZ publish 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 Johansen
Netmaking AS

http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Claus Jensen

Sunday 14 December 2003 11:51:15 pm

Morning,
Its working in ezpublish 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

and the output when I run it is:
<b>Fatal error</b>: Call to a member function on a non-object in <b>/data/ezpublish/3.2-1/met_imp_final.php</b> on line <b>84</b><br />
Fatal error: eZ publish did not finish it's request
The execution of eZ publish was abruptly ended.

If somebody has a clue, please let me know.
claÜs

Eirik Alfstad Johansen

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.

Sincerely,

Eirik Johansen
Netmaking AS

http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 03:15:22
Script start
Timing: Jan 19 2025 03:15:22
Module start 'layout'
Timing: Jan 19 2025 03:15:22
Module start 'content'
Timing: Jan 19 2025 03:15:23
Module end 'content'
Timing: Jan 19 2025 03:15:23
Script end

Main resources:

Total runtime0.8301 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.0391152.6094
Module start 'layout' 0.00550.0028 741.648439.4297
Module start 'content' 0.00830.8201 781.0781560.4141
Module end 'content' 0.82840.0017 1,341.492212.1875
Script end 0.8301  1,353.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4029160.0002
Check MTime0.00140.1705160.0001
Mysql Total
Database connection0.00060.073610.0006
Mysqli_queries0.765992.2601600.0128
Looping result0.00060.0707580.0000
Template Total0.798296.220.3991
Template load0.00230.277620.0012
Template processing0.795995.878220.3980
Template load and register function0.00020.020010.0002
states
state_id_array0.00080.096210.0008
state_identifier_array0.00170.210320.0009
Override
Cache load0.00200.2421630.0000
Sytem overhead
Fetch class attribute can translate value0.00050.054520.0002
Fetch class attribute name0.00130.161250.0003
XML
Image XML parsing0.00080.091020.0004
class_abstraction
Instantiating content class attribute0.00000.003160.0000
General
dbfile0.00190.2246160.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 32
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs