public function setBehaviour($behaviour) { if (!in_array($behaviour, array('ignore', 'cascade'))) { throw $this->exception('Unknonw join behaviour')->addMoreInfo('behaviour', $behaviour)->addMoreInfo('supported', array('ignore', 'cascade')); } $this->model->addHook('beforeInsert', array($this, 'insertInForeingTable')); $this->model->addHook('beforeUpdate', array($this, 'updateInForeingTable')); $this->model->addHook('afterDelete', array($this, 'deleteInForeignTable')); $this->behaviour = $behaviour; return $this; }
/** * This method "cooks" related model. * * @param SQL_Model $m * @param bool $as_array * @param bool $limit * @param int $offset * @param bool $order * @param bool $desc * @return array|SQL_Model */ function prepareRelated(\SQL_Model $m, $as_array = false, $limit = false, $offset = 0, $order = false, $desc = true) { if ($limit) { $m->setLimit($limit, $offset); } if ($order) { $m->setOrder($order, $desc); } if ($as_array) { return $m->getRows(); } return $m; }
/** * @param SQL_Model $model * @return DB_dsql */ public function getExpression($model) { $refModel = $this->getModel(); if (is_string($refModel)) { $refModel = $this->app->normalizeClassName($refModel, 'Model'); } $refModel = $this->add($refModel); /** @type SQL_Model $refModel */ $other = $model->dsql()->getField($this->getForeignFieldName()); if ($this->table()) { $other = $model->dsql()->expr($this->table() . '.' . $this->getForeignFieldName()); } return $refModel->dsql()->field($refModel->title_field)->where($refModel->id_field, $other); }
public function ref($mode = null) { if (!$this->owner->loaded()) { throw $this->exception('Model must be loaded before traversing reference'); } if ($mode == 'model') { /** @type SQL_Model $m */ $m = $this->add($this->model_name); return $m->addCondition($this->their_field, $this->owner->get($this->our_field)); } $this->restoreConditions(); $this->model->unload(); return $this->model->addCondition($this->their_field, $this->owner->get($this->our_field)); }
/** * Prepare create-table action * * @param SQL_Model $model * * @return void */ function createTable(\SQL_Model $model) { if ($this->is_default_id_field) { // default ID field $type = 'integer'; $auto = 'auto_increment'; } else { // custom ID field $field = $model->getElement($model->id_field); $type = $this->mapFieldType($field); $auto = ''; } // register action $this->actions['create-table'] = array('template' => $this->templates['create-table'], 'tags' => array('table' => $model->table, 'field' => $model->id_field, 'type' => $type, 'auto_incr' => $auto, 'engine' => $this->engine)); }
function init() { parent::init(); $this->addField('name'); $this->hasMany('Rule'); $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']); }
function init() { parent::init(); $this->addField("session_id"); $this->addField("data")->type("text"); $this->addField("timestamp")->type("text"); }
function init() { parent::init(); $this->hasOne('Industry'); $this->hasOne('Company'); $this->hasOne('Department'); $this->hasOne('Category'); $this->addField('type')->enum(['routine', 'activity rule', 'task rule']); $this->addField('name'); $this->addField('is_template')->type('boolean')->defaultValue(false); $this->addField('applicable_on')->type('text'); $this->addField('is_done')->type('boolean')->defaultValue(false); $this->addField('auto_status')->type('text'); $this->addField('moderated_by')->enum(['SVC Admin', 'Company Owner', 'Manager', 'Self', 'None']); $this->addField('is_mandatory')->type('boolean'); $this->addField('applicable')->enum(['daily', 'weekly']); $this->addField('is_self_addable')->type('boolean'); $this->addField('cross_check')->type('Number'); // $this->containsMany('cross_check_options',function($m){ // $m->addField('name'); // $m->addField('gMarks')->type('text'); // }); $this->hasMany('RuleOption'); $this->hasMany('gMarks'); $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']); }
function init() { parent::init(); $this->addField('name')->caption('Volume Name')->mandatory(true)->sortable(true); $this->addField('dirname')->caption('Folder')->hint('You can use absolute path too')->mandatory(true)->sortable(true); /* // @todo there is no implementation of total_space and used_space $this->addField('total_space') ->caption('Total space') ->hint('Volume size limit (bytes)') ->type('int') ->mandatory(true) ->defaultValue('1000000000') ->sortable(true) ; $this->addField('used_space') ->caption('Used space') ->hint('Space used by files (bytes)') ->type('int') ->mandatory(true) ->defaultValue(0) ->display(array('form'=>'Readonly')) ->sortable(true) ; */ $this->addField('stored_files_cnt')->caption('Files')->hint('Count of files in volume')->type('int')->mandatory(true)->defaultValue(0)->display(array('form' => 'Readonly'))->sortable(true); $this->addField('enabled')->caption('Writable')->hint('Be sure to check this one!')->type('boolean')->mandatory(true)->defaultValue(false)->sortable(true); }
function init() { parent::init(); $this->hasOne('dokku_alt/Host'); $this->addField('ts')->type('datetime')->defaultValue(date('Y-m-d H:i:s')); $this->addField('line'); }
function init() { parent::init(); $this->addField('email'); $this->addField('password'); $this->add('dynamic_model/Controller_AutoCreator_MySQL'); }
function init() { parent::init(); $this->hasOne('dokku_alt/DB', null, null, 'DB'); $this->hasOne('dokku_alt/App', null, null, 'App'); $this->addHook('beforeSave,beforeDelete', $this); }
function init() { parent::init(); $this->addField('name')->caption('Volume Name')->mandatory(true)->sortable(true); $this->addField('dirname_field', 'dirname')->caption('Folder')->hint('You can use absolute path too')->mandatory(true)->sortable(true)->system(true); $this->addExpression('dirname')->set($this->dsql()->expr('CONCAT("websites/[0]/",[1])', [$this->app->current_website_name, $this->getElement('dirname_field')]))->caption('Folder')->hint('You can use absolute path too')->mandatory(true)->sortable(true); /* // @todo there is no implementation of total_space and used_space $this->addField('total_space') ->caption('Total space') ->hint('Volume size limit (bytes)') ->type('int') ->mandatory(true) ->defaultValue('1000000000') ->sortable(true) ; $this->addField('used_space') ->caption('Used space') ->hint('Space used by files (bytes)') ->type('int') ->mandatory(true) ->defaultValue(0) ->display(array('form'=>'Readonly')) ->sortable(true) ; */ $this->addField('stored_files_cnt')->caption('Files')->hint('Count of files in volume')->type('int')->mandatory(true)->defaultValue(0)->display(array('form' => 'Readonly'))->sortable(true); $this->addField('enabled')->caption('Writable')->hint('Be sure to check this one!')->type('boolean')->mandatory(true)->defaultValue(false)->sortable(true); }
function init() { parent::init(); //fields $this->addField('name'); $this->addField('ui_name'); $this->addField('is_active')->type('boolean'); }
function init() { parent::init(); $this->addField('name')->caption('Your Name'); $this->addField('ref')->system(true); $this->addField('descr')->caption('Suggestion or Feedback')->type('text'); $this->addField('date')->system(true)->defaultValue(date('Y-m-d')); }
function init() { parent::init(); $this->addField('content'); $this->addField('block_id'); $this->addField('is_deleted'); //->type('boolean'); }
function init() { parent::init(); $this->hasOne('dokku_alt/App'); $this->addField('is_redirect')->type('boolean'); $this->addField('name'); $this->addHook('afterSave,afterDelete', [$this, 'setDomains']); }
function init() { parent::init(); $this->addField('name')->caption('Name')->mandatory(true)->sortable(true); $this->addField('mime_type')->caption('MIME type')->mandatory(true)->sortable(true); $this->addField('extension')->caption('Filename extension')->mandatory(true)->sortable(true); $this->addField('allow')->caption('Allow')->hint('Be sure to check this one!')->type('boolean')->defaultValue(true)->mandatory(true)->sortable(true); }
function init() { parent::init(); $this->hasOne('dokku_alt/App'); $this->addField('name'); $this->addField('value'); $this->addHook('beforeInsert,beforeDelete,beforeModify', $this); }
function init() { parent::init(); $this->hasOne('RuleBook'); $this->addField('name'); $this->addField('gMarks')->type('text'); $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']); }
function init() { parent::init(); $this->addField('name'); $this->addField('mime_type'); $this->addField('extension'); // TODO: extension should be substituted when recording filename }
function init() { parent::init(); $this->addField('page_id'); $this->addField('language'); $this->addField('meta_title'); $this->addField('meta_keywords'); $this->addField('meta_description'); }
function init() { parent::init(); //$this->hasOne('dokku_alt/App'); $this->addField('type'); $this->addField('fingerprint'); $this->addField('publickey')->type('text')->caption('Public Key'); $this->addField('privatekey')->type('text')->hint('Optional')->caption('Private Key'); }
function init() { parent::init(); $this->hasOne('Company'); $this->hasOne('User'); $this->hasOne('Rule'); $this->addField('gmarks'); $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']); }
function init() { parent::init(); $this->hasOne('xepan\\commerce\\Item_CustomField_Generic', 'customfield_generic_id'); $this->hasOne('xepan\\commerce\\Item_CustomField_Value', 'customfield_value_id'); $this->hasOne('xepan\\commerce\\Model_Store_TransactionRow', 'store_transaction_row_id'); $this->addField('custom_name'); $this->addField('custom_value'); }
function init() { parent::init(); $this->addField('name'); $this->addField('type')->enum(['mongodb', 'mariadb', 'postrgresql', 'redis', 'memcache'])->mandatory(true); $this->addHook('beforeInsert,beforeDelete', $this); $this->hasOne('dokku_alt/Host'); $this->hasMany('dokku_alt/DB_Link', null, null, 'DB_Link'); }
function init() { parent::init(); $this->addField('host'); $this->addField('notes')->type('text'); $this->addField('data')->type('text'); $this->addField('is_secure')->type('boolean')->editable(false)->hint('Will use your current passkey to encrypt'); $this->hasOne('User')->defaultValue($this->app->auth->model->id); $this->addHook('beforeUpdate', array($this, 'checkSecurity')); }
function init() { parent::init(); $this->hasOne('User')->defaultValue($this->api->auth->model->id); $this->addField('subject'); $this->addField('content')->type('text')->display(['form' => 'RichText']); $this->add('filestore/Field_Image', 'image_id')->caption('Default Image'); $this->addField('created_at')->type('datetime')->defaultValue($this->api->now); $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']); }
function defineFields() { parent::defineFields(); $this->addField('title')->mandatory(true); $this->addField('keywords'); $this->addField('inherit'); $this->addField('descr')->type('text'); $this->addField('example')->type('text'); $this->addField('approved')->type('boolean'); }
function init() { parent::init(); $this->addField('key')->system(true)->visible(true)->editable(true)->readonly(true)->sortable(true); $this->addField('tr_en')->sortable(true); $this->addField('tr_de')->sortable(true); $this->addField('tr_ru')->sortable(true); $this->addField('tr_lv')->sortable(true); // extend and add your language }