Beispiel #1
0
 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);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 public function testGetOneNotExists()
 {
     $name = $this->db->getOne('SELECT name FROM test WHERE id = 100');
     $this->assertNull($name);
 }
Beispiel #4
0
 protected function getRowCount()
 {
     return $this->db->getOne('SELECT count(*) FROM test');
 }