本文整理匯總了PHP中sql::expr方法的典型用法代碼示例。如果您正苦於以下問題:PHP sql::expr方法的具體用法?PHP sql::expr怎麽用?PHP sql::expr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sql
的用法示例。
在下文中一共展示了sql::expr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: excludeDeleted
/**
* @return sql_select
* @param sql_select $query
* @param string $alias
*/
public static function excludeDeleted(sql_select $query = null, $alias = null)
{
if (null === $query) {
$query = self::createQuery(get_called_class(), $alias);
}
return $query->where(sql::expr(($alias ? $alias . '.' : '') . 'deleted', '=', 0));
}
示例2: testHaving
public function testHaving()
{
self::assertEquals("select * from t having (a = 'b')", sql::select(sql::ALL)->from('t')->having(sql::expr('a', '=', 'b'))->toString(Nano::db()));
self::assertEquals("select * from t having (a = 'b') and (c = 'd')", sql::select(sql::ALL)->from('t')->having(sql::expr('a', '=', 'b'))->having(sql::expr('c', '=', 'd'))->toString(Nano::db()));
self::assertEquals("select * from t having (a = 'b') or (c = 'd')", sql::select(sql::ALL)->from('t')->having(sql::expr('a', '=', 'b'))->orHaving(sql::expr('c', '=', 'd'))->toString(Nano::db()));
self::assertEquals("select * from t having custom expr", sql::select(sql::ALL)->from('t')->having(sql::custom('custom expr'))->toString(Nano::db()));
self::assertEquals("select * from t having custom expr", sql::select(sql::ALL)->from('t')->having('custom expr')->toString(Nano::db()));
}
示例3: testNestedExpr
public function testNestedExpr()
{
$expected = "((a = 'b') and (c = 'd')) or ((e = 'f') and (g = 'h'))";
$expr = sql::expr(sql::expr('a', '=', 'b')->addAnd('c', '=', 'd'))->addOr(sql::expr('e', '=', 'f')->addAnd('g', '=', 'h'));
self::assertEquals($expected, $expr->toString(Nano::db()));
}