public function testDeleteJoin() { $db = new DatabaseSqliteStandalone(':memory:'); $db->query('CREATE TABLE a (a_1)', __METHOD__); $db->query('CREATE TABLE b (b_1, b_2)', __METHOD__); $db->insert('a', array(array('a_1' => 1), array('a_1' => 2), array('a_1' => 3)), __METHOD__); $db->insert('b', array(array('b_1' => 2, 'b_2' => 'a'), array('b_1' => 3, 'b_2' => 'b')), __METHOD__); $db->deleteJoin('a', 'b', 'a_1', 'b_1', array('b_2' => 'a'), __METHOD__); $res = $db->query("SELECT * FROM a", __METHOD__); $this->assertResultIs(array(array('a_1' => 1), array('a_1' => 3)), $res); }
/** * Returns version of currently supported SQLite fulltext search module or false if none present. * @return String */ static function getFulltextSearchModule() { static $cachedResult = null; if ($cachedResult !== null) { return $cachedResult; } $cachedResult = false; $table = 'dummy_search_test'; $db = new DatabaseSqliteStandalone(':memory:'); if ($db->query("CREATE VIRTUAL TABLE {$table} USING FTS3(dummy_field)", __METHOD__, true)) { $cachedResult = 'FTS3'; } $db->close(); return $cachedResult; }
/** * @covers DatabaseSqlite::numFields */ public function testNumFields() { $db = new DatabaseSqliteStandalone(':memory:'); $databaseCreation = $db->query('CREATE TABLE a ( a_1 )', __METHOD__); $this->assertInstanceOf('ResultWrapper', $databaseCreation, "Failed to create table a"); $res = $db->select('a', '*'); $this->assertEquals(0, $db->numFields($res), "expects to get 0 fields for an empty table"); $insertion = $db->insert('a', array('a_1' => 10), __METHOD__); $this->assertTrue($insertion, "Insertion failed"); $res = $db->select('a', '*'); $this->assertEquals(1, $db->numFields($res), "wrong number of fields"); $this->assertTrue($db->close(), "closing database"); }
public function testInsertIdType() { $db = new DatabaseSqliteStandalone(':memory:'); $this->assertInstanceOf('ResultWrapper', $db->query('CREATE TABLE a ( a_1 )', __METHOD__), "Database creationg"); $this->assertTrue($db->insert('a', array('a_1' => 10), __METHOD__), "Insertion worked"); $this->assertEquals("integer", gettype($db->insertId()), "Actual typecheck"); $this->assertTrue($db->close(), "closing database"); }
public function testCaseInsensitiveLike() { // TODO: Test this for all databases $db = new DatabaseSqliteStandalone(':memory:'); $res = $db->query('SELECT "a" LIKE "A" AS a'); $row = $res->fetchRow(); $this->assertFalse((bool) $row['a']); }