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 -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

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