CakePHP 1.3 an alternative to SoftDeletable Behavior?

Does anyone know an alternative to SoftDeletable Behavior that is compatible with Cake 1.3.x

If there is no ready-made behavior, any suggestions on how I do this in the last cake?


Found out a quick hack. First of all, if your table represents a tinyint (1) unsigned field named remote , which defaults to 0 .

In app / app_model.php add the following function:

function softDelete( $id ) { if( $id && $this->hasField( 'deleted' ) ) { $this->id = $id; return $this->saveField( 'deleted', 1 ); } return false; } 

and then from your controller method (which does the deletion),

 $this->Model->softDelete( $id ); 

Catch - wherever you execute find () , you need to specify the deleted! = 1 condition.

Still trying to figure out how to implement this in the same way as SoftDeletable behavior.

+4
source share
2 answers

I adapted the behavior of marians to 1.3. look here https://github.com/evilbloodydemon/cakephp-softdeletable2

+5
source

Also worth noting: there is a SoftDelete behavior bundled with the CakeDC Utils plugin .

+3
source

Source: https://habr.com/ru/post/1332452/


All Articles