本文整理匯總了PHP中DBQuery::select方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBQuery::select方法的具體用法?PHP DBQuery::select怎麽用?PHP DBQuery::select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBQuery
的用法示例。
在下文中一共展示了DBQuery::select方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: select
public static function select($table, $condition)
{
$query = DBQuery::select($table);
$query = self::applyCondition($query, $condition);
$result = $query->act();
if (!is_array($condition)) {
// returning object if [int $id]
return $result->fetch();
} else {
// returning DBResult otherwise
return $result;
}
}
示例2: toggleStatus
public function toggleStatus($id)
{
$params = array();
$query = new DBQuery();
$query->select('validado');
$query->from($this->table);
$query->where($this->identifier . ' = ' . (int) $id);
$status = (bool) DB::getInstance()->getValue($query);
$status = !$status;
$params['validado'] = (int) $status;
return DB::getInstance()->update($this->table, $params, $this->identifier . ' = ' . (int) $id);
}
示例3: testAct
/**
* 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);
}