get() public method

public get ( $name = null )
Example #1
0
File: Many.php Project: atk4/atk4
 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));
 }
Example #2
0
File: Field.php Project: atk4/atk4
 /**
  * Get value of this field formatted for SQL. Redefine if you need to convert.
  *
  * @return mixed
  */
 public function getSQL()
 {
     $val = $this->owner->get($this->short_name);
     if ($this->type == 'boolean') {
         $val = $this->getBooleanValue($val);
     }
     if ($val == '' && !$this->mandatory && ($this->listData || $this instanceof Field_Reference) && $this->type != 'boolean') {
         $val = null;
     }
     return $val;
 }
Example #3
0
 public function beforeInsert($m, $q)
 {
     // Insert related table data and add ID into the main query
     // TODO: handle cases when $this->m1 != $this->owner->table?:$this->owner->table_alias
     if ($this->delete_behaviour == 'ignore') {
         return;
     }
     if ($this->owner->hasElement($this->m2) && $this->owner->get($this->m2) !== null) {
         return;
         // using existing element
     }
     $this->dsql->set($this->f2, null);
     $this->id = $this->dsql->insert();
     if ($this->relation) {
         $q = $this->relation->dsql;
     }
     $q->set($this->m2, $this->id);
 }