/** * Column Modify * * @param string $table Table name * @param string $field Column definition * * @return bool */ public function modifyColumn($table, $field) { // Work-around for literal column definitions is_array($field) or $field = [$field]; foreach (array_keys($field) as $k) { $this->addField([$k => $field[$k]]); } if (count($this->fields) === 0) { throw new \RuntimeException('Field information is required'); } $sqls = $this->_alterTable('CHANGE', $this->db->DBPrefix . $table, $this->_processFields()); $this->_reset(); if ($sqls === false) { if ($this->db->DBDebug) { throw new DatabaseException('This feature is not available for the database you are using.'); } return false; } for ($i = 0, $c = count($sqls); $i < $c; $i++) { if ($this->db->query($sqls[$i]) === false) { return false; } } return true; }
/** * Decrements a numeric column by the specified value. * * @param string $column * @param int $value * * @return bool */ public function decrement(string $column, int $value = 1) { $column = $this->db->protectIdentifiers($column); $sql = $this->_update($this->QBFrom[0], [$column => "{$column}-{$value}"]); return $this->db->query($sql, $this->binds); }