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