Ruckusing_Adapter_MySQL_TableDefinition::__construct PHP Method

__construct() public method

Creates an instance of Ruckusing_Adapters_MySQL_Adapter
public __construct ( Ruckusing_Adapter_MySQL_Base $adapter, string $name, array $options = [] ) : Ruckusing_Adapter_MySQL_TableDefinition
$adapter Ruckusing_Adapter_MySQL_Base the current adapter
$name string the table name
$options array the options
return Ruckusing_Adapter_MySQL_TableDefinition
    public function __construct($adapter, $name, $options = array())
    {
        //sanity check
        if (!$adapter instanceof Ruckusing_Adapter_MySQL_Base) {
            throw new Ruckusing_Exception("Invalid MySQL Adapter instance.", Ruckusing_Exception::INVALID_ADAPTER);
        }
        if (!$name) {
            throw new Ruckusing_Exception("Invalid 'name' parameter", Ruckusing_Exception::INVALID_ARGUMENT);
        }
        $this->_adapter = $adapter;
        $this->_name = $name;
        $this->_options = $options;
        $this->init_sql($name, $options);
        $this->_table_def = new Ruckusing_Adapter_TableDefinition($this->_adapter, $this->_options);
        if (array_key_exists('id', $options)) {
            if (is_bool($options['id']) && $options['id'] == false) {
                $this->_auto_generate_id = false;
            }
            //if its a string then we want to auto-generate an integer-based
            //primary key with this name
            if (is_string($options['id'])) {
                $this->_auto_generate_id = true;
                $this->_primary_keys[] = $options['id'];
            }
        }
    }