Changeset 7552
- Timestamp:
- 02/20/08 11:35:52 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelActAsCountableBehaviorPlugin/tags/0.1/README
r7048 r7552 111 111 }}} 112 112 113 This method is resource intensive, so if you want to manipulate your countable objects more easily, for instance to achieve a sort by number of counts in a single query, you should add a `nb_sf_counts` column to your object to keep the number of counts. The behavior will keep this column up to date, provided that you declare it in the `app.yml`: 114 {{{ 115 all: 116 sfPropelActAsCountableBehaviorPlugin: 117 count: 118 enabled: true # whether or not the method must be called for updating the count 119 method: setNbSfCounts # name of the method to call in order to update the count. If you call the comments count column "gerard", simply put "setGerard" on this line 120 }}} 121 122 With this trick, sorting objects by their counter value is rather straightforward: 123 {{{ 124 $c = new Criteria(); 125 $c->addDescendingOrderByColumn(PostPeer::NB_SF_COUNTS); 126 $posts = PostPeer::doSelect($c); 127 }}} 128 113 129 == API == 114 130 The behavior implement the following methods: … … 143 159 == Changelog == 144 160 161 === Trunk - 2008-02-20 === 162 163 * francois: Added automatic update of `nb_sf_counts` columns 164 145 165 === version 0.1 - 2008-01-14 === 146 166 Initial public release. plugins/sfPropelActAsCountableBehaviorPlugin/tags/0.1/lib/sfPropelActAsCountableBehavior.class.php
r7048 r7552 172 172 173 173 $object->_counter->save(); 174 175 $count_options = array_merge(array('method' => 'setNbSfCounts', 176 'enabled' => true), 177 sfConfig::get('app_sfPropelActAsCountableBehaviorPlugin_count', array())); 178 179 if ($count_options['enabled'] && is_callable(get_class($object), $count_options['method'])) 180 { 181 call_user_func(array($object, $count_options['method']), $object->_counter->getCounter()); 182 $object->save(); 183 } 174 184 } 175 185 }