views:

427

answers:

2

If I have one of my PHP Doctrine objects act as a SoftDelete, is it possible to include deleted items in the results of certain queries? What I'm looking for is something like this...

$q = Doctrine_Query::create()
    ->select('*')
    ->from('Test t')
    ->where('id < ?', 25)
    *->includeDeleted()*;

Something like this would be useful as for most queries I want deleted records excluded, but sometimes (for example, to administrators) I want to be able to include records that have been soft deleted. Is there some good way to do this with SoftDelete or should I simply add an additional where clause onto most queries?

Thank you!

+1  A: 

From a cursory glance at the source here and here, this functionality does not seem to provided by the SoftDelete behaviour. You have to add a where clause manually like you suggest.

(I may be wrong, but I'm pretty sure Doctrine_Query can not be extended dynamically by way of a behaviour like you can with Doctrine_Record. You could always write a special Doctrine_Query subclass which adds includeDeleted(), but that seems like more thouble than it's worth :) )

Øystein Riiser Gundersen
A: 

Solution deleted

Daniel Pozzi