Initializing eZ when not using CLI or eZ publish

Author Message

Atle Pedersen

Monday 14 May 2007 6:54:26 am

Hi,

I need to get some data from the eZ database using for example:
$node =& eZContentObjectTreeNode::fetch( 2 );

However I am using a php program that is called directly from apache, and not from CLI nor from within eZ publish.

My guess is that I need to to some initializing of some sorts, but I don't know what.

Can anyone point me in the right direction?

Michael Maclean

Tuesday 15 May 2007 2:56:41 am

The minimum that I've managed to get away with so far has been:

include_once('lib/ezutils/classes/ezini.php');
include_once('lib/ezutils/classes/ezsys.php');
include_once('lib/ezdb/classes/ezdb.php');
include_once('access.php');
include_once( "lib/ezutils/classes/ezdebugsetting.php" );
include_once( "kernel/classes/ezcontentobjecttreenode.php" );

/*!
  Dummy function, required by some scripts in eZ publish.
*/
function eZUpdateDebugSettings( $useDebug = null )
{
}

$ini = eZINI::instance();

// This will get the default siteaccess name, or you can hard code it if you want
// $siteaccess = 'accessname';
$siteaccess = $ini->variable( 'SiteSettings', 'DefaultAccess' );
$access = array( 'name' => $siteaccess, 'type' => EZ_ACCESS_TYPE_DEFAULT );
$access = changeAccess( $access );

$node = eZContentObjectTreeNode::fetch( 2 );
var_dump($node);

You will probably need to change the paths to the includes.

eZpedia community documentation project | http://ezpedia.org

Atle Pedersen

Thursday 24 May 2007 6:23:59 am

Thank you Michael, this was excatly what I needed.

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 18 2025 14:56:08
Script start
Timing: Jan 18 2025 14:56:08
Module start 'layout'
Timing: Jan 18 2025 14:56:08
Module start 'content'
Timing: Jan 18 2025 14:56:09
Module end 'content'
Timing: Jan 18 2025 14:56:09
Script end

Main resources:

Total runtime0.9644 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 588.0469152.6406
Module start 'layout' 0.00890.0030 740.687539.4766
Module start 'content' 0.01190.9513 780.1641531.8906
Module end 'content' 0.96320.0012 1,312.054712.1250
Script end 0.9643  1,324.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.3758160.0002
Check MTime0.00130.1390160.0001
Mysql Total
Database connection0.00240.247310.0024
Mysqli_queries0.914294.7960570.0160
Looping result0.00050.0548550.0000
Template Total0.927996.220.4640
Template load0.00280.290420.0014
Template processing0.925195.930720.4626
Template load and register function0.00010.010410.0001
states
state_id_array0.00100.108110.0010
state_identifier_array0.00110.114220.0006
Override
Cache load0.00240.2500170.0001
Sytem overhead
Fetch class attribute can translate value0.00070.067920.0003
Fetch class attribute name0.00100.104540.0003
XML
Image XML parsing0.00070.076420.0004
class_abstraction
Instantiating content class attribute0.00000.001250.0000
General
dbfile0.00100.1089160.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs