Changeset 4562
- Timestamp:
- 06/25/08 19:24:01 (7 months ago)
- Files:
-
- 1 modified
-
branches/0.11/manual/docs/en/plugins.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/manual/docs/en/plugins.txt
r4385 r4562 225 225 </code> 226 226 227 Now lets put the plugin in action: 228 229 <code type="php"> 227 Now lets put the plugin in action. 228 229 Note: You are required to enable DQL callbacks in order for all executed queries to have the dql callbacks 230 executed on them. In the SoftDelete behavior they are used to filter the select statements to exclude all 231 records where the deleted flag is set with an additional WHERE condition. 232 233 <code type="php"> 234 // Enable dql callbacks. 235 Doctrine_Manager::getInstance()->setAttribute('use_dql_callbacks', true); 230 236 231 237 // save a new record … … 236 242 $record->delete(); 237 243 var_dump($record->deleted); // true 244 245 // Querying for records excludes deleted records automatically. 246 $q = Doctrine_Query::create() 247 ->from('SoftDeleteTest t'); 248 249 echo $q->count(); // This would be 0, it would exclude the record saved above because the delete flag was set 250 // The following SQL would have been executed to get this count 251 // SELECT COUNT(DISTINCT s.name) AS num_results FROM soft_delete_test s WHERE s.deleted = ? GROUP BY s.name 252 253 echo $q->getSql(); // SELECT s.name AS s__name, s.something AS s__something, s.deleted AS s__deleted FROM soft_delete_test s WHERE s.deleted = ? 238 254 </code> 239 255