示例#1
0
 /**
  * Creates an UPDATE command that increments/decrements certain columns.
  * Override parent implementation to check if an orderby clause if specified when querying with an offset
  *
  * @param TableSchema $table    the table metadata
  * @param array       $counters counters to be updated (counter increments/decrements indexed by column names.)
  * @param Criteria    $criteria the query criteria
  *
  * @return Command the created command
  * @throws \Exception if no counter is specified
  */
 public function createUpdateCounterCommand($table, $counters, $criteria)
 {
     $criteria = $this->checkCriteria($table, $criteria);
     return parent::createUpdateCounterCommand($table, $counters, $criteria);
 }
示例#2
0
 /**
  * Creates an UPDATE command.
  *
  * @param mixed    $table    the table schema ({@link TableSchema}) or the table name (string).
  * @param array    $data     list of columns to be updated (name=>value)
  * @param Criteria $criteria the query criteria
  *
  * @throws \Exception if no columns are being updated for the given table
  * @return Command update command.
  */
 public function createUpdateCommand($table, $data, $criteria)
 {
     foreach ($data as $name => $value) {
         if (($column = $table->getColumn($name)) !== null) {
             if ($column->autoIncrement) {
                 unset($data[$name]);
                 continue;
             }
         }
     }
     return parent::createUpdateCommand($table, $data, $criteria);
 }