當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Association::name方法代碼示例

本文整理匯總了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;
 }
開發者ID:QoboLtd,項目名稱:cakephp-csv-views,代碼行數:24,代碼來源:CsvViewComponent.php

示例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;
 }
開發者ID:QoboLtd,項目名稱:cakephp-csv-migrations,代碼行數:40,代碼來源:ViewViewTabsListener.php


注:本文中的Cake\ORM\Association::name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。