/** * Initializes base query for model $m. * * @param Model $m * * @return \atk4\dsql\Query */ public function initQuery($m) { $d = $m->persistence_data['dsql'] = $this->connection->dsql(); if ($m->table) { if (isset($m->table_alias)) { $d->table($m->table, $m->table_alias); } else { $d->table($m->table); } } return $d; }
public function testException4() { $c = new Connection(); $q = $c->expr('select (2+2)'); $this->assertEquals('select (2+2)', $q->render()); $this->setExpectedException('atk4\\dsql\\Exception'); $q->execute(); }
public function testSQLite() { $c = Connection::connect($GLOBALS['DB_DSN'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASSWD']); return (string) $c->expr("SELECT date('now')")->getOne(); }
public function __construct() { $this->c = Connection::connect($GLOBALS['DB_DSN'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASSWD']); $this->pdo = $this->c->connection(); $this->pdo->query('CREATE TEMPORARY TABLE employee (id int not null, name text, surname text, retired bool, PRIMARY KEY (id))'); }