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