本文整理汇总了PHP中Condition::_OR方法的典型用法代码示例。如果您正苦于以下问题:PHP Condition::_OR方法的具体用法?PHP Condition::_OR怎么用?PHP Condition::_OR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::_OR方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTimeline
public static function getTimeline($user, $offset = 0, $max = 20)
{
if ($user == NULL) {
throw new Exception('user is null');
}
// Messages belonging to me or the users I follow
$_or = Condition::_OR()->add(Condition::EQ(self::TABLE, 'createdBy_id', $user->getId()));
// I want to see my messages also
$following = $user->getFollowing();
foreach ($following as $otherUser) {
$_or->add(Condition::EQ(self::TABLE, 'createdBy_id', $otherUser->getId()));
}
// Paginated search
// Messages ordered by createdOn, first the last messages
$list = Message::findBy($_or, new ArrayObject(array('sort' => 'createdOn', 'dir' => 'desc', 'offset' => $offset, 'max' => $max)));
return $list;
}
示例2: countBy
/**
* FIXME: pasarle la clase, no una instancia.
*/
public function countBy($ins, $condition)
{
Logger::getInstance()->pm_log("PM::countBy");
$objTableName = YuppConventions::tableName($ins);
$params = array();
// Quiero solo los registros de las subclases y ella misma.
$class = get_class($ins);
$scs = ModelUtils::getAllSubclassesOf($class);
$scs[] = $class;
// Definicion de la condicion.
$cond_total = Condition::_AND();
if (count($scs) == 1) {
$cond_total->add(Condition::EQ($objTableName, "class", $scs[0]));
} else {
$cond = Condition::_OR();
foreach ($scs as $subclass) {
$cond->add(Condition::EQ($objTableName, "class", $subclass));
}
$cond_total->add($cond);
}
// FIXED: igual que en findByAttributeMatrix usada por findBy
// Si no tiene condicion deleted, le pone deleted false.
if ($condition == NULL || !$condition->hasCondForAttr('deleted')) {
$cond_total->add(Condition::EQ($objTableName, "deleted", 0));
}
// CRITERIO DE BUSQUEDA
if ($condition != NULL) {
$cond_total->add($condition);
}
$params['where'] = $cond_total;
return $this->dal->count($objTableName, $params);
}