/** * Method to test modifyColumn(). * * @return void * * @covers Windwalker\Query\Mysql\MysqlQueryBuilder::modifyColumn */ public function testModifyColumn() { $expected = "ALTER TABLE {$this->qn('foo')} MODIFY {$this->qn('bar')} int(11) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Test' FIRST"; $actual = MysqlQueryBuilder::modifyColumn('foo', 'bar', 'int(11)', false, false, '1', 'FIRST', 'Test'); $this->assertEquals($this->format($expected), $this->format($actual)); }
/** * modifyColumn * * @param string|Column $name * @param string $type * @param bool $signed * @param bool $allowNull * @param string $default * @param string $comment * @param array $options * * @return static */ public function modifyColumn($name, $type = 'text', $signed = true, $allowNull = true, $default = '', $comment = '', $options = array()) { if ($name instanceof Column) { $column = $name; $length = $column->getLength(); $name = $column->getName(); $type = $column->getType(); $signed = $column->getSigned(); $allowNull = $column->getAllowNull(); $default = $column->getDefault(); $position = $column->getPosition(); $comment = $column->getComment(); } else { $position = isset($options['position']) ? $options['position'] : null; } $type = MysqlType::getType($type); $length = isset($length) ? $length : MysqlType::getLength($type); $length = $length ? '(' . $length . ')' : null; $query = MysqlQueryBuilder::modifyColumn($this->table, $name, $type . $length, $signed, $allowNull, $default, $position, $comment); $this->db->setQuery($query)->execute(); return $this; }