Forums / Developer / PHP: get nodes and compare to class_id

PHP: get nodes and compare to class_id

Author Message

Jorge estévez

Wednesday 24 March 2010 7:33:09 am

Helo,

This is ezpublish versión 3.10.1

I am searching in PHP for all items at ezcontentobject table, and I assumed that the “Id” was the Node_id of the item but it seems It isn’t. How can I get the node_Id of the node? Or is there a table I can search for all objects and get the node_id of each one of them?

I need to:

Access the database table XXXX

Get all nodes, and compare (foreach) if each one of them belongs to class No XXX

If someone has a tip, I am making my first approach to database searching.

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Bruce Morrison

Wednesday 24 March 2010 5:10:49 pm

Hi Jorge

The DB table that holds nodes is ezcontentobject_tree but you'll have to join this with ezcontentobject to access the class. Have a look at http://ez.no/doc/ez_publish/technical_manual/3_10/concepts_and_basics/content_management/the_content_node for some of the underlying info.

I'm not sure exactly what you are trying to achieve but typically in eZ Publish you utilise the API to retrieve data and don't do direct queries on the DB. The easiest way to retrieve the data you are after is a template fetch query from PHP:

$nodes = eZFunctionHandler::execute( 'content', 'tree',
    array( 'parent_node_id'     => $top_node_id,
           'class_filter_type'  => 'include',
           'class_filter_array' => array( 'article' ) ) );

As the filtering is done in the fetch there is no need to loop through the returned nodes and check class type.

This is quite flexible as you can utilise the same parameters as used in templates.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jorge estévez

Thursday 25 March 2010 5:10:33 am

Thanks

Is there a way to donwload the whole API Reference instead of reading online?

Best Regards

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Jorge estévez

Thursday 25 March 2010 5:15:18 am

Found at http://pubsvn.ez.no/doxygen/3.10/

thanks again!

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

eZ debug

Timing: Jan 29 2025 13:40:59
Script start
Timing: Jan 29 2025 13:40:59
Module start 'content'
Timing: Jan 29 2025 13:40:59
Module end 'content'
Timing: Jan 29 2025 13:40:59
Script end

Main resources:

Total runtime0.1384 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 587.9531180.8281
Module start 'content' 0.00640.0121 768.781398.5078
Module end 'content' 0.01850.1199 867.2891526.3281
Script end 0.1384  1,393.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00332.3838200.0002
Check MTime0.00140.9778200.0001
Mysql Total
Database connection0.00191.402710.0019
Mysqli_queries0.087763.37431410.0006
Looping result0.00100.75601390.0000
Template Total0.119586.310.1195
Template load0.00080.587310.0008
Template processing0.118785.714010.1187
Override
Cache load0.00060.403810.0006
Sytem overhead
Fetch class attribute can translate value0.00070.494810.0007
XML
Image XML parsing0.00020.159010.0002
General
dbfile0.00634.5713200.0003
String conversion0.00000.002930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs