Пример #1
0
 /**
  * Tests act()
  * 
  * @test
  */
 public function testAct()
 {
     // inserting
     $inserted_id = DBQuery::insert('tests')->set('foo', 'bar', 'bar', 'foo')->act();
     $this->assertSame(mysql_insert_id(), $inserted_id);
     // selecting
     $foo = DBQuery::select('tests')->where('id', $inserted_id)->act()->fetch();
     $this->assertEquals($inserted_id, $foo->id);
     $this->assertEquals('bar', $foo->foo);
     $this->assertEquals('foo', $foo->bar);
     // updating
     $this->assertSame(1, DBQuery::update('tests')->set('foo', 1, 'bar', 2)->where('id', $inserted_id)->act());
     // deleting
     $this->assertSame(1, DBQuery::delete('tests')->where('id', $inserted_id)->act());
     $this->assertFalse(DBQuery::select('tests')->where('id', $inserted_id)->act()->exists);
 }
Пример #2
0
 public static function update($table, $condition, $fields)
 {
     $query = DBQuery::update($table)->set($fields);
     $query = self::applyCondition($query, $condition);
     return $query->act();
 }