Exemple #1
0
 /**
  * Set values to the query.
  * The method can execute multiple times. The passed array require the
  * same amount of elements, otherwise an exception will thrown.
  *
  * @param array $values An usual array with the values that should insert.
  *
  * @return $this The same instance to concatenate methods.
  */
 public function values(array $values)
 {
     $valuesArray = array();
     foreach ($values as $value) {
         $valuesArray[] = $this->factory->references('Value', $value);
     }
     $this->insert->values($valuesArray);
     return $this;
 }
Exemple #2
0
 /**
  * Create table objects from the passed arguments.
  * An array will return with the key 'table' for the main table and 'optionalTables' for optional tables.
  * When no optional tables are passed, the key 'optionalTables' return an empty array.
  *
  * @param string $table          Name of the main table.
  * @param array  $optionalTables Optional table names, hold in an array.
  *
  * @return array Array with prepared table objects, format: ['table' => $tbl, 'optionalTables' => array].
  */
 private function _getPreparedTableObjects($table, array $optionalTables)
 {
     $tableObj = $this->factory->references('Table', $table);
     $optionalTablesObj = array();
     foreach ($optionalTables as $tbl) {
         $optionalTablesObj[] = $this->factory->references('Table', $tbl);
     }
     return array('table' => $tableObj, 'optionalTables' => $optionalTablesObj);
 }
Exemple #3
0
 /**
  * Add an order by expression to the query.
  *
  * @param string      $column    Column Name.
  * @param string|null $orderMode Order mode, whether desc or asc.
  *
  * @return $this The same instance to concatenate methods.
  */
 public function orderBy($column, $orderMode = null)
 {
     /** @var ColumnInterface $columnObj */
     $columnObj = $this->factory->references('Column', $column);
     /** @var OrderModeEnumInterface $orderModeObj */
     $orderModeObj = $orderMode ? $this->factory->references('OrderModeEnum', $orderMode) : null;
     $this->update->orderBy($columnObj, $orderModeObj);
     return $this;
 }
Exemple #4
0
 /**
  * Build objects from the passed arguments.
  * The values will returned as assoc array in the following form:
  * array('column' => $column, 'compareValue' = $value).
  * $column is of type References\Column. When the type argument is equal to 'column',
  * $value is also of type References\Column, otherwise of References\Value.
  * The
  *
  * @param string $column       Name of the column for the comparison.
  * @param string $compareValue Compare value.
  * @param string $type         Type of the compare value, whether column or usual value.
  *
  * @return array Array with prepared objects.
  */
 private function _getPrepareObjectsArray($column, $compareValue, $type)
 {
     $columnObj = $this->factory->references('Column', $column);
     if ($type === 'column') {
         $compareObj = $this->factory->references('Column', $compareValue);
     } else {
         $compareObj = $this->factory->references('Value', $compareValue);
     }
     return array('column' => $columnObj, 'compareValue' => $compareObj);
 }