Ejemplo n.º 1
0
 protected function setUp()
 {
     if (!$this->db) {
         $this->db = \Fobia\DataBase\DbFactory::create('mysql://root@localhost/mysql');
     }
     $this->q = $this->db->createSelectQuery();
 }
Ejemplo n.º 2
0
 /**
  * @covers Fobia\DataBase\Query\QueryReplace::getQuery
  * @todo   Implement testGetQuery().
  */
 public function testGetQuery()
 {
     $q = $this->db->createReplaceQuery();
     $str = "REPLACE INTO user ( Host, User, Password ) VALUES ( 'localhost', 'test', '' )";
     $q->insertInto('user')->set('Host', $this->db->quote('localhost'))->set('User', $this->db->quote('test'))->set('Password', $this->db->quote(''));
     $this->assertEquals($str, $q->getQuery());
 }
Ejemplo n.º 3
0
 /**
  * @covers Fobia\DataBase\Query\QueryInsert::getQuery
  * @todo   Implement testGetQuery().
  */
 public function testGetQuery()
 {
     $q = $this->db->createInsertQuery();
     $str = "INSERT INTO user ( Host, User, Password ) VALUES ( 'localhost', 'test', '' )";
     $q->set('Host', $this->db->quote('localhost'))->set('User', $this->db->quote('test'))->set('Password', $this->db->quote(''));
     $qi = clone $q;
     $q->insertInto('user');
     $qi->insertIntoIgnore('user');
     $this->assertEquals($str, $q->getQuery());
     $this->assertRegExp('/^INSERT IGNORE /', $qi->getQuery());
 }
Ejemplo n.º 4
0
 /**
  * @covers Fobia\DataBase\DbStatement::__destruct
  * @todo   Implement test__destruct().
  */
 public function test__destruct()
 {
     $stmt = $this->db->query("SELECT VERSION()");
     unset($stmt);
 }
Ejemplo n.º 5
0
 public function testRollback()
 {
     $this->db->beginTransaction();
     $this->assertTrue($this->db->rollback());
 }
Ejemplo n.º 6
0
 /**
  * @covers Fobia\DataBase\Query\QueryUpdate::getQuery
  * @todo   Implement testGetQuery().
  */
 public function testGetQuery()
 {
     $q = $this->q;
     $q->update('test')->orderBy('test')->limit(1)->set('id', $this->db->quote(2))->where($q->expr->eq('id', $this->db->quote(1)));
     $this->assertEquals("UPDATE test SET id = '2' WHERE id = '1' ORDER BY test LIMIT 1", $q->getQuery());
 }