本文整理汇总了PHP中Cake\ORM\Association::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Association::find方法的具体用法?PHP Association::find怎么用?PHP Association::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Association
的用法示例。
在下文中一共展示了Association::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _deleteFileAssociationRecord
/**
* Method that fetches and deletes document-file manyToMany association record Entity.
*
* @param string $id file id
* @return bool
*/
protected function _deleteFileAssociationRecord($id)
{
$query = $this->_fileStorageAssociation->find('all', ['conditions' => [$this->_fileStorageForeignKey => $id]]);
$entity = $query->first();
if (is_null($entity)) {
return false;
}
return $this->_fileStorageAssociation->delete($entity);
}
示例2: find
/**
* Proxies the finding operation to the target table's find method
* and modifies the query accordingly based of this association
* configuration.
*
* If your association includes conditions, the junction table will be
* included in the query's contained associations.
*
* @param string|array $type the type of query to perform, if an array is passed,
* it will be interpreted as the `$options` parameter
* @param array $options The options to for the find
* @see \Cake\ORM\Table::find()
* @return \Cake\ORM\Query
*/
public function find($type = null, array $options = [])
{
$query = parent::find($type, $options);
if (!$this->conditions()) {
return $query;
}
$belongsTo = $this->junction()->association($this->target()->alias());
$conditions = $belongsTo->_joinCondition(['foreignKey' => $this->foreignKey()]);
return $this->_appendJunctionJoin($query, $conditions);
}
示例3: _loadBelongsToMany
/**
* Loads a list of belongs to many from ids.
*
* @param Association $assoc The association class for the belongsToMany association.
* @param array $ids The list of ids to load.
* @return array An array of entities.
*/
protected function _loadBelongsToMany($assoc, $ids)
{
$target = $assoc->target();
$primaryKey = (array) $target->primaryKey();
$multi = count($primaryKey) > 1;
if ($multi) {
if (count(current($ids)) !== count($primaryKey)) {
return [];
}
$filter = new TupleComparison($primaryKey, $ids, [], 'IN');
} else {
$filter = [$primaryKey[0] . ' IN' => $ids];
}
return $assoc->find()->where($filter)->toArray();
}