public function __construct($config, $name) { if (is_array($config)) { $config = array_merge($this->default_connection_config(), $config); if (empty($config['dsn'])) { if ($dsn = $this->build_dsn($config)) { $config['dsn'] = $dsn; } else { throw new Exception\ErrorException(sprintf("Not enough info to create DSN string for connection '%s'", $name)); } } $this->pdo = $this->create_connection($config); } elseif ($config instanceof PDO) { $this->pdo = $config; } else { throw new Exception\InvalidArgumentException('Connection must be either array or instance of PDO.'); } $this->adapter_name = ActiveRecord::proper_adapter_name($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)); $this->name = $name; }
private function _get_builder_class() { $cn = $this->model_name; $class = '\\Rails\\ActiveRecord\\Adapter\\'; $class .= ActiveRecord::proper_adapter_name($cn::connection()->adapterName()); $class .= '\\QueryBuilder'; return $class; }
protected function get_table_class() { $model = $this->_current_model; $adapter = ActiveRecord::proper_adapter_name($model::connection()->adapterName()); $cn = 'Rails\\ActiveRecord\\Adapter\\' . $adapter . '\\Table'; return $cn; }