Forums / Developer / PHP: get nodes and compare to class_id
Jorge estévez
Wednesday 24 March 2010 7:33:09 am
Helo,
This is Exponential 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 Exponential 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.
CheersBruce
My Blog: http://www.stuffandcontent.com/ Follow me on twitter: http://twitter.com/brucemorrison Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish
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
Thursday 25 March 2010 5:15:18 am
Found at http://pubsvn.ez.no/doxygen/3.10/
thanks again!