本文整理汇总了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);
}