Changeset 4562

Show
Ignore:
Timestamp:
06/25/08 19:24:01 (7 months ago)
Author:
jwage
Message:

Added documentation for #1170

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/manual/docs/en/plugins.txt

    r4385 r4562  
    225225</code> 
    226226 
    227 Now lets put the plugin in action: 
    228  
    229 <code type="php"> 
     227Now lets put the plugin in action. 
     228 
     229Note: You are required to enable DQL callbacks in order for all executed queries to have the dql callbacks  
     230executed on them. In the SoftDelete behavior they are used to filter the select statements to exclude all  
     231records where the deleted flag is set with an additional WHERE condition. 
     232 
     233<code type="php"> 
     234// Enable dql callbacks. 
     235Doctrine_Manager::getInstance()->setAttribute('use_dql_callbacks', true); 
    230236 
    231237// save a new record 
     
    236242$record->delete(); 
    237243var_dump($record->deleted); // true 
     244 
     245// Querying for records excludes deleted records automatically. 
     246$q = Doctrine_Query::create() 
     247        ->from('SoftDeleteTest t'); 
     248 
     249echo $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 
     253echo $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 = ? 
    238254</code> 
    239255