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