本文整理匯總了PHP中Cake\ORM\Association::name方法的典型用法代碼示例。如果您正苦於以下問題:PHP Association::name方法的具體用法?PHP Association::name怎麽用?PHP Association::name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\ORM\Association
的用法示例。
在下文中一共展示了Association::name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _oneToManyAssociatedRecords
/**
* Method that retrieves one to many associated records
* @param \Cake\ORM\Table $table Table object
* @param \Cake\ORM\Association $association Association object
* @return array associated records
*/
protected function _oneToManyAssociatedRecords(\Cake\ORM\Table $table, \Cake\ORM\Association $association)
{
$assocName = $association->name();
$assocTableName = $association->table();
$assocForeignKey = $association->foreignKey();
$recordId = $this->request->params['pass'][0];
// get associated index View csv fields
$fields = $this->_getTableFields($association);
$query = $table->{$assocName}->find('all', ['conditions' => [$assocForeignKey => $recordId], 'fields' => $fields]);
$records = $query->all();
// store associated table records
$result['records'] = $records;
// store associated table fields
$result['fields'] = $fields;
// store associated table name
$result['table_name'] = $assocTableName;
return $result;
}
示例2: _oneToManyAssociatedRecords
/**
* Method that retrieves one to many associated records
*
* @param \Cake\ORM\Association $association Association object
* @param \Cake\Network\Request $request passed
* @return array associated records
*/
protected function _oneToManyAssociatedRecords(Association $association, Request $request)
{
$result = [];
$assocName = $association->name();
$assocTableName = $association->table();
$assocForeignKey = $association->foreignKey();
$recordId = $request->params['pass'][0];
$csvFields = $this->_getAssociationCsvFields($association, static::ASSOC_FIELDS_ACTION);
if (empty($csvFields)) {
return $result;
}
// get associated index View csv fields
$fields = array_unique(array_merge([$association->displayField()], $csvFields));
$query = $this->_tableInstance->{$assocName}->find('all', ['conditions' => [$assocForeignKey => $recordId]]);
$records = $query->all();
// store association name
$result['assoc_name'] = $assocName;
// store associated table name
$result['table_name'] = $assocTableName;
// store associated table class name
$result['class_name'] = $association->className();
// store associated table display field
$result['display_field'] = $association->displayField();
// store associated table primary key
$result['primary_key'] = $association->primaryKey();
// store associated table foreign key
$result['foreign_key'] = $association->foreignKey();
// store associated table fields
$result['fields'] = $fields;
// store associated table records
$result['records'] = $records;
return $result;
}