本文整理汇总了PHP中Cake\ORM\Query::triggerBeforeFind方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::triggerBeforeFind方法的具体用法?PHP Query::triggerBeforeFind怎么用?PHP Query::triggerBeforeFind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Query
的用法示例。
在下文中一共展示了Query::triggerBeforeFind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: triggerBeforeFind
/**
* Cake\ORM\Query::triggerBeforeFind overwritten to add the condition `deleted IS NULL` to every find request
* in order not to return soft deleted records.
* If the query contains the option `withDeleted` the condition `deleted IS NULL` is not applied.
*/
public function triggerBeforeFind()
{
if (!$this->_beforeFindFired && $this->_type === 'select') {
parent::triggerBeforeFind();
$aliasedField = $this->repository()->aliasField($this->repository()->getSoftDeleteField());
if (!is_array($this->getOptions()) || !in_array('withDeleted', $this->getOptions())) {
$this->andWhere($aliasedField . ' = 1');
}
}
}
示例2: _dispatchBeforeFind
/**
* Triggers beforeFind on the target table for the query this association is
* attaching to
*
* @param \Cake\ORM\Query $query the query this association is attaching itself to
* @return void
*/
protected function _dispatchBeforeFind($query)
{
$query->triggerBeforeFind();
}