Exemplo n.º 1
0
 function testSqlBufferProperty()
 {
     $db = new PixelDb();
     $this->assertNotNull($db->getSqlBuffer());
     $newBuffer = new StringBuffer();
     $newBuffer->append('SAMPLE BUFFER');
     $db->setSqlBuffer($newBuffer);
     $this->assertEquals('SAMPLE BUFFER', $db->getSqlString());
 }
Exemplo n.º 2
0
 function testFrom()
 {
     $pixelDb = new PixelDb();
     $pixelDb->select(['username', 'password'])->select(['mstoken', 'fbtoken', 'gotoken'], 'auths.')->from(['users', 'auths']);
     $this->assertEquals('SELECT username, password, auths.mstoken, auths.fbtoken, auths.gotoken FROM users, auths', $pixelDb->getSqlString());
 }
Exemplo n.º 3
0
 function testTwoSet()
 {
     $pixelDb = new PixelDb();
     $pixelDb->update('users')->set(['username' => 'Antigya Avaga'])->set(['password' => 'New Password'], null, 'sensitive_');
     $this->assertEquals('UPDATE users SET username = :p_username, password = :sensitive_password', $pixelDb->getSqlString());
 }
Exemplo n.º 4
0
 function testTwoSelect()
 {
     $pixeldb = new PixelDb();
     $pixeldb->select(['username', 'password'])->select(['title', 'description'], 'post.');
     $this->assertEquals('SELECT username, password, post.title, post.description', $pixeldb->getSqlString());
 }
Exemplo n.º 5
0
 public function testDelete()
 {
     $db = new PixelDb();
     $db->delete('users');
     $this->assertEquals('DELETE FROM users', $db->getSqlString());
 }
Exemplo n.º 6
0
 function testUpdate()
 {
     $pixelDb = new PixelDb();
     $pixelDb->update('users');
     $this->assertEquals('UPDATE users', $pixelDb->getSqlString());
 }
Exemplo n.º 7
0
 function testTwoOrderBy()
 {
     $pixelDb = new PixelDb();
     $pixelDb->select(['*'])->from(['users'])->orderBy('username')->orderBy('register_date', OrderByExpression::ORDER_DIRECTION_DESCENDING);
     $this->assertEquals('SELECT * FROM users ORDER BY username ASC, register_date DESC', $pixelDb->getSqlString());
 }
Exemplo n.º 8
0
 function testWhereOrWithFunction()
 {
     $pixelDb = new PixelDb();
     $pixelDb->select(['*'])->from(['users'])->where('username', 'abumyria')->orWhere('password', 'avaga', 'SHA1');
     $this->assertEquals('SELECT * FROM users WHERE username = :p_username OR password = SHA1(:p_password)', $pixelDb->getSqlString());
 }
Exemplo n.º 9
0
 function testLimit()
 {
     $pixelDb = new PixelDb();
     $pixelDb->select(['*'])->from(['users'])->limit(0, 10);
     $this->assertEquals('SELECT * FROM users LIMIT 0, 10', $pixelDb->getSqlString());
 }