当前位置: 首页>>代码示例>>PHP>>正文


PHP Association::table方法代码示例

本文整理汇总了PHP中Cake\ORM\Association::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Association::table方法的具体用法?PHP Association::table怎么用?PHP Association::table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\ORM\Association的用法示例。


在下文中一共展示了Association::table方法的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::table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。