예제 #1
0
파일: Many.php 프로젝트: atk4/atk4
 public function refSQL($mode = null)
 {
     if ($mode == 'model') {
         /** @type SQL_Model $m */
         $m = $this->add($this->model_name);
         return $m->addCondition($this->their_field, $this->owner->getElement($this->our_field));
     }
     $this->restoreConditions();
     return $this->model->addCondition($this->their_field, $this->owner->getElement($this->our_field));
 }
예제 #2
0
파일: Relation.php 프로젝트: atk4/atk4
 public function hasOne($model, $our_field = UNDEFINED, $field_class = UNDEFINED)
 {
     // @todo Should check field types. There is some kind of mix of SQL fields and base fields
     /** @type Field_SQL_HasOne $field */
     $field = $this->model->hasOne($model, $our_field, $field_class);
     $field->table($this->joinAlias);
     /** @type Field_SQL_HasOne $foreign_field */
     $foreign_field = $this->model->getElement($field->getForeignFieldName());
     $foreign_field->table($this->joinAlias);
     return $field;
 }
예제 #3
0
파일: MySQL.php 프로젝트: xepan/xepan
 /**
  * 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));
 }