示例#1
0
 /**
  * Set values for the columns, which are passed as array argument in the UpdateFacade::columns() method.
  * You have to call this method immediate after the columns method.
  * Before calling this method again, the columns() has to be invoked.
  *
  * @param array $values An usual array with the values as elements.
  *
  * @return $this The same instance to concatenate methods.
  * @throws \Exception When the UpdateFacade::columns() method was not called before.
  */
 public function values(array $values)
 {
     $columnsArraySize = count($this->columnsArray);
     if ($columnsArraySize === 0 || $columnsArraySize !== count($values)) {
         throw new \Exception('Columns method must called before and both passed array require the same amount of elements');
     }
     foreach ($this->columnsArray as $number => $column) {
         /** @var ColumnInterface $columnObj */
         $columnObj = $this->factory->references('Column', $column);
         $valueObj = $this->factory->references('Value', $values[$number]);
         $this->update->column($columnObj)->value($valueObj);
     }
     return $this;
 }
示例#2
0
 /**
  * Add a column to the query. When this method would not called, a * wildcard will set.
  *
  * @param string      $name     Name of the column.
  * @param string|null $tableRef (Optional) Name of the referred table, if exists.
  * @param string|null $alias    (Optional) An alias name, if exists.
  *
  * @return $this The same instance to concatenate methods.
  */
 public function column($name, $tableRef = null, $alias = null)
 {
     $column = $this->factory->references('Column', $name, $tableRef, $alias);
     $this->select->column($column);
     return $this;
 }