public function __construct() { $config = Config::GetConfig(); $this->_dba = DatabaseAdapter::Create($config['db_adapter']); $this->_dba->connect($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_flags']); // Connect to the default database // @todo Move this decision out of this class if (class_exists('Bootstrap', false)) { $this->_dba->selectDatabase(Bootstrap::GetDefaultDatabase()); // @todo Abstraction violation! } else { $default_db = Config::GetValue('default_db'); if (isset($default_db)) { $this->_dba->selectDatabase($default_db); // @todo Hack! } } return; }
function test_Relation() { $this->assertEqual(DatabaseAdapter::Filter('name', ATTR_IS, 'foobar'), "(name = 'foobar')"); $this->assertEqual(DatabaseAdapter::Filter('name', ATTR_IS_NOT, 'foobar'), "(name <> 'foobar')"); $this->assertEqual(DatabaseAdapter::Filter('name', ATTR_HAS, 'bcd'), "(name = '%bcd%')"); $this->assertEqual(DatabaseAdapter::Filter('name', ATTR_HAS_NO, 'bcd'), "(name <> '%bcd%')"); $this->assertEqual(DatabaseAdapter::Filter('type', ATTR_IN, array('foo', 'bar', 'baz')), "(type IN ('foo', 'bar', 'baz'))"); $this->assertEqual(DatabaseAdapter::Filter('type', ATTR_NOT_IN, array('foo', 'bar', 'baz')), "(type NOT IN ('foo', 'bar', 'baz'))"); $this->assertEqual(DatabaseAdapter::Filter('volume', ATTR_BETWEEN, array(1, 5)), "(volume BETWEEN 1 AND 5)"); $this->assertEqual(DatabaseAdapter::Filter('volume', ATTR_OUTSIDE, array(0, 5)), "(volume NOT BETWEEN 0 AND 5)"); }
/** * @param DatabaseAdapter $_adapter * @return unknown_type */ public function accept(DatabaseAdapter $_adapter) { return $_adapter->assign($this->connection, $this->table, $this->primary, $this->index); }
private function getConditions() { return DatabaseAdapter::Filter($this->conditions); }