/** * * Model-specific setup. * * @return void * */ protected function _setup() { parent::_setup(); $this->_hasMany('areas'); $this->_hasMany('nodes'); $this->_hasOne('pref'); }
/** * * Fetches a new record and appends it to the collection. * * @param array $spec An array of data for the new record. * * @return Solar_Sql_Model_Record The newly-appended record. * */ public function appendNew($spec = null) { // create a new record from the spec and append it $record = $this->_model->fetchNew($spec); $this->_data[] = $record; return $record; }
/** * * Fixes the element description in-place. * * @param array &$elem The element to work with. * * @param string $name The original element name (column name). * * @param string $col The column definition used to inform the element. * * @return void * */ protected function _fixElementDescr(&$elem, $name, $col) { if ($elem['descr'] !== null) { return; } // if no label specified, set up based on element name $elem['descr'] = $this->_model->locale(strtoupper("DESCR_{$name}")); }
/** * * Deletes the cache for this model and all related models. * * @return void * */ public function deleteAll() { $this->delete(); foreach ($this->_model->related as $name => $info) { $model = $this->_model->getRelated($name)->getModel(); $model->cache->delete(); } }
/** * * Model-specific setup. * * @return void * */ protected function _setup() { // chain to parent parent::_setup(); $this->_belongsTo('area'); $this->_belongsTo('area_false', array('foreign_name' => 'areas', 'where' => '0=1')); $this->_belongsTo('user'); $this->_hasOne('meta'); $this->_hasOne('meta_false', array('foreign_name' => 'metas', 'where' => '0=1')); $this->_hasMany('comments'); $this->_hasMany('comments_false', array('foreign_name' => 'comments', 'where' => '0=1', 'join_flag' => true)); $this->_hasMany('taggings'); $this->_hasManyThrough('tags', 'taggings'); $this->_hasManyThrough('tags_false', 'taggings', array('foreign_name' => 'tags', 'where' => '0=1')); $this->_hasMany('taggings_false', array('foreign_name' => 'taggings', 'where' => '0=1')); $this->_hasManyThrough('tags_through_false', 'taggings_false', array('foreign_name' => 'tags')); $this->_hasManyThrough('tags_false_through_false', 'taggings_false', array('foreign_name' => 'tags', 'where' => '0=1')); }
/** * * Model-specific setup. * * @return void * */ protected function _setup() { parent::_setup(); $this->_belongsTo('user'); $this->_hasMany('nodes'); }
/** * * Returns an INNER JOIN specification for joining to the native table as * as sub-SELECT. * * @param Solar_Sql_Model_Params_Eager $eager The eager params. * * @param Solar_Sql_Model_Params_Fetch $fetch The native fetch settings. * * @param string $col The foreign column to join against. * * @return array A join specification array. * */ protected function _getNativeBySelect($eager, $fetch, $col) { // get a *copy* of the fetch params; don't want to mess them up // for other eagers. only use the joins marked "keep". $clone = $fetch->cloneForKeeps(); // reset the column list and get only the native column $clone['cols'] = array(); $clone->cols($this->native_col); // for all sub-eagers, if they are joining to the top-level fetch, // make sure they are join_only ... otherwise, they'll add columns, // which will mess up our cols() from earlier. foreach ($clone['eager'] as $sub_eager) { if ($sub_eager['join_flag']) { $sub_eager['join_only'] = true; } } // don't waste time ordering the results $clone['order'] = false; // build a select and get it as a string $select = $this->_native_model->newSelect($clone); $string = $select->__toString(); $join = array('type' => "inner", 'name' => "({$string}) AS {$fetch['alias']}", 'cond' => "{$fetch['alias']}.{$this->native_col} = {$col}", 'cols' => null); // done! return $join; }
/** * * Model-specific setup. * * @return void * */ protected function _setup() { parent::_setup(); $this->_belongsTo('user'); }
/** * * Overrides normal locale() to use the **model** locale strings. * * @param string $key The key to get a locale string for. * * @param string $num If 1, returns a singular string; otherwise, returns * a plural string (if one exists). * * @param array $replace An array of replacement values for the string. * * @return string The locale string, or the original $key if no * string found. * */ public function locale($key, $num = 1, $replace = null) { return $this->_model->locale($key, $num, $replace); }
/** * * Create a new record related to this one. * * @param string $name The relation name. * * @param array $data Initial data * * @return Solar_Sql_Model_Record * */ public function newRelated($name, $data = null) { $related = $this->_model->getRelated($name); $new = $related->fetchNew($data); return $new; }
/** * * Model-specific setup. * * @return void * */ protected function _setup() { parent::_setup(); $this->_belongsTo('node'); $this->_belongsTo('tag'); }
/** * * Model-specific setup. * * @return void * */ protected function _setup() { parent::_setup(); $this->_hasMany('taggings'); $this->_hasManyThrough('nodes', 'taggings'); }