phalcon - PhalconPHP - set the default foreign key action -


is there way define default foreign key action used in every model don't have keep defining inside every model below?

$this->hasone('id', '\namespace', 'id', [     'foreignkey' => [         'action' => \phalcon\mvc\model\relation::action_cascade     ] ]); 

override hasone().

class yourbasemodel extends \phalcon\mvc\model {      protected function hasone($local, $remote_model, $remote_field, $options = null) {         $options['foreignkey'] = [             'action' => \phalcon\mvc\model\relation::action_cascade         ];          parent::hasone($local, $remote_model, $remote_field, $options);     }  }  class yourmodel extends yourbasemodel {      public function initialize() {         $this->hasone('id', '\namespace', 'id');     }  } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -