Ruckusing_Adapter_Sqlite3_Base::add_column PHP Method

add_column() public method

public add_column ( string $table_name, string $column_name, string $type, array $options = [] ) : boolean
$table_name string
$column_name string
$type string
$options array
return boolean
    public function add_column($table_name, $column_name, $type, $options = array())
    {
        if (empty($table_name)) {
            throw new Ruckusing_Exception("Missing table name parameter", Ruckusing_Exception::INVALID_ARGUMENT);
        }
        if (empty($column_name)) {
            throw new Ruckusing_Exception("Missing column name parameter", Ruckusing_Exception::INVALID_ARGUMENT);
        }
        if (empty($type)) {
            throw new Ruckusing_Exception("Missing type parameter", Ruckusing_Exception::INVALID_ARGUMENT);
        }
        $defaultOptions = array('limit' => null, 'precision' => null, 'scale' => null);
        $options = array_merge($defaultOptions, $options);
        $sql = sprintf("ALTER TABLE %s ADD COLUMN %s %s", $this->quote_table_name($table_name), $this->quote_column_name($column_name), $this->type_to_sql($type, $options));
        $sql .= $this->add_column_options($type, $options);
        return $this->execute_ddl($sql);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Add a column
  *
  * @param string $table_name the name of the table
  * @param string $column_name the column name
  * @param string $type the column type
  * @param array|string $options
  *
  * @return boolean
  */
 public function add_column($table_name, $column_name, $type, $options = array())
 {
     return $this->_adapter->add_column($table_name, $column_name, $type, $options);
 }