本文整理汇总了PHP中CActiveRecord::defaultScope方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::defaultScope方法的具体用法?PHP CActiveRecord::defaultScope怎么用?PHP CActiveRecord::defaultScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::defaultScope方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defaultScope
/**
* Returns the default named scope that should be implicitly applied to all queries for this model.
* @return array the query criteria.
*/
public function defaultScope()
{
$scope = parent::defaultScope();
if ($this->hasAttribute('status')) {
$tableAlias = $this->getTableAlias(true, false);
$condition = $tableAlias . '.status>=0';
$scope['condition'] = isset($scope['condition']) ? '(' . $scope['condition'] . ') AND (' . $condition . ')' : $condition;
}
return $scope;
}
示例2: defaultScope
/**
* Returns the default named scope that should be implicitly applied to all queries for this model.
* @return array the query criteria.
*/
public function defaultScope()
{
$scope = parent::defaultScope();
if ($this->hasAttribute('status')) {
$tableAlias = $this->getTableAlias(true, false);
$condition = $tableAlias . '.status >= 0';
if (isset($scope['condition'])) {
if (strpos($scope['condition'], 'status') === false) {
$scope['condition'] = '(' . $scope['condition'] . ') AND (' . $condition . ')';
}
} else {
$scope['condition'] = $condition;
}
}
return $scope;
}
示例3: defaultScope
public function defaultScope()
{
parent::defaultScope();
return array('condition' => "post_type='post'");
}