public function testInsertIgnore() { $data = ['id' => 1, 'code' => '003', 'name' => 'Pan', 'price' => '22.9']; $id = $this->db->insert('test', $data, true); $code = $this->db->getOne('SELECT code FROM test WHERE id = 1'); $this->assertEquals('001', $code); $this->assertTrue($id); }
public function testTransactionRollback() { $this->db->beginTransaction(); $this->db->query("INSERT INTO test (id, code, price) VALUES (3001, '1', 1)"); $this->db->rollback(); $id = $this->db->getOne("SELECT id FROM test WHERE id = 3001"); $this->assertNull($id); }
public function testGetOneNotExists() { $name = $this->db->getOne('SELECT name FROM test WHERE id = 100'); $this->assertNull($name); }
protected function getRowCount() { return $this->db->getOne('SELECT count(*) FROM test'); }