Is this good ?

Author Message

Katrien Cogghe

Wednesday 22 March 2006 6:36:03 am

Hi,

In the following code I remove all the objects with the content 'ez publish 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,'<','ez publish 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

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 04:26:17
Script start
Timing: Jan 19 2025 04:26:17
Module start 'layout'
Timing: Jan 19 2025 04:26:17
Module start 'content'
Timing: Jan 19 2025 04:26:17
Module end 'content'
Timing: Jan 19 2025 04:26:17
Script end

Main resources:

Total runtime0.0211 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 590.1641152.6094
Module start 'layout' 0.00760.0036 742.773439.3984
Module start 'content' 0.01120.0077 782.171985.2109
Module end 'content' 0.01880.0021 867.382830.3047
Script end 0.0209  897.6875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002612.1835140.0002
Check MTime0.00125.5101140.0001
Mysql Total
Database connection0.00157.181610.0015
Mysqli_queries0.003516.589130.0012
Looping result0.00000.112910.0000
Template Total0.00178.010.0017
Template load0.00094.330010.0009
Template processing0.00073.538310.0007
Override
Cache load0.00063.059410.0006
General
dbfile0.00167.522680.0002
String conversion0.00000.041840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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