Forums / Developer / Is this good ?
Katrien Cogghe
Wednesday 22 March 2006 6:36:03 am
Hi,
In the following code I remove all the objects with the content 'Exponential sucks' in a specific attribute. But I was wondering if 'purge' is the good way to do this.
I really want to delete the complete objects, but I'm not sure if the object would also been delete if it is a related object from another object.
Maybe there is a possibility to write this code shorter/faster ?
And what with the caching ?
if ( is_numeric( $node_id ) and is_numeric( $class_id ) and is_numeric ( $attr_id )) { $node =& eZContentObjectTreeNode::fetch( $node_id ); $tree=eZContentObjectTreeNode::subTree( array( 'ClassFilterArray' => array($class_id), 'ClassFilterType' => 'include', 'AttributeFilter' => array('AND',array($attr_id,'<','Exponential sucks')), 'mainNodeOnly' => true), $node_id ) ; foreach ($tree as $item) { $item_node_id = $item->attribute( 'node_id' ); $object = eZContentObject::fetchByNodeID( $item_node_id ); $object->purge(); } }
Thanks a lot,
Katrien