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


PHP BaseActiveRecord::populateRecord方法代码示例

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


在下文中一共展示了BaseActiveRecord::populateRecord方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: populateRecord

 /**
  * @inheritdoc
  */
 public static function populateRecord($record, $row)
 {
     $columns = static::getTableSchema()->columns;
     foreach ($row as $name => $value) {
         if (isset($columns[$name])) {
             $row[$name] = $columns[$name]->phpTypecast($value);
         }
     }
     parent::populateRecord($record, $row);
 }
开发者ID:avron99,项目名称:delayed-orders,代码行数:13,代码来源:ActiveRecord.php

示例2: populateRecord

 /**
  * Populates an active record object using a xunsearch result document
  *
  * @param ActiveRecord $record the record to be populated.
  * @param \XSDocument $doc
  */
 public static function populateRecord($record, $doc)
 {
     parent::populateRecord($record, $doc->getFields());
     $record->setInternalDoc($doc);
 }
开发者ID:Kuner,项目名称:xunsearch,代码行数:11,代码来源:ActiveRecord.php

示例3: populateRecord

 /**
  * @inheritdoc
  */
 public static function populateRecord($record, $row)
 {
     $attributes = [];
     if (isset($row['_source'])) {
         $attributes = $row['_source'];
     }
     if (isset($row['fields'])) {
         // reset fields in case it is scalar value TODO use field metadata for this
         foreach ($row['fields'] as $key => $value) {
             if (count($value) == 1) {
                 $row['fields'][$key] = reset($value);
             }
         }
         $attributes = array_merge($attributes, $row['fields']);
     }
     parent::populateRecord($record, $attributes);
     $pk = static::primaryKey()[0];
     //TODO should always set ID in case of fields are not returned
     if ($pk === '_id') {
         $record->_id = $row['_id'];
     }
     $record->_highlight = isset($row['highlight']) ? $row['highlight'] : null;
     $record->_score = isset($row['_score']) ? $row['_score'] : null;
     $record->_version = isset($row['_version']) ? $row['_version'] : null;
     // TODO version should always be available...
 }
开发者ID:aivavic,项目名称:yii2,代码行数:29,代码来源:ActiveRecord.php

示例4: populateRecord

 /**
  * @inheritdoc
  */
 public static function populateRecord($record, $row)
 {
     $columns = static::getIndexSchema()->columns;
     foreach ($row as $name => $value) {
         if (isset($columns[$name]) && $columns[$name]->isMva) {
             $row[$name] = explode(',', $value);
         }
     }
     parent::populateRecord($record, $row);
 }
开发者ID:sciurodont,项目名称:yii2,代码行数:13,代码来源:ActiveRecord.php

示例5: populateRecord

 /**
  * Populates an active record object using a row of data from the database/storage.
  *
  * This is an internal method meant to be called to create active record objects after
  * fetching data from the database. It is mainly used by [[ActiveQuery]] to populate
  * the query results into active records.
  *
  * When calling this method manually you should call [[afterFind()]] on the created
  * record to trigger the [[EVENT_AFTER_FIND|afterFind Event]].
  *
  * @param static $record The record to be populated. In most cases this will be an instance
  * created by [[instantiate()]] beforehand.
  * @param array  $row    Attribute values (name => value).
  * @return void
  */
 public static function populateRecord($record, $row)
 {
     $responseData = ArrayHelper::getValue($row, Query::RESPONSE_KEY_PARAM);
     unset($row[Query::RESPONSE_KEY_PARAM]);
     parent::populateRecord($record, $row);
     if (!empty($responseData)) {
         $record->_responseData = $responseData;
     }
 }
开发者ID:petrabarus,项目名称:yii2-dynamodb,代码行数:24,代码来源:ActiveRecord.php

示例6: populateRecord

 /**
  * @inheritdoc
  */
 public static function populateRecord($record, $row)
 {
     $columns = static::getIndexSchema()->columns;
     foreach ($row as $name => $value) {
         if (isset($columns[$name])) {
             if ($columns[$name]->isMva) {
                 $mvaValue = explode(',', $value);
                 $row[$name] = array_map([$columns[$name], 'phpTypecast'], $mvaValue);
             } else {
                 $row[$name] = $columns[$name]->phpTypecast($value);
             }
         }
     }
     parent::populateRecord($record, $row);
 }
开发者ID:howq,项目名称:yii2,代码行数:18,代码来源:ActiveRecord.php

示例7: populateRecord

 /**
  * @inheritdoc
  * @throws \yii\base\UnknownPropertyException
  */
 public static function populateRecord($record, $row)
 {
     $attributes = array_flip($record->attributes());
     foreach ($attributes as $attributeName => $attributeValue) {
         if (!array_key_exists($attributeName, $row)) {
             throw new UnknownPropertyException("Attribute `{$attributeName}` not found in API response. Available fields: " . implode(', ', array_keys($row)) . '.');
         }
     }
     parent::populateRecord($record, $row);
 }
开发者ID:apexwire,项目名称:yii2-restclient,代码行数:14,代码来源:ActiveRecord.php

示例8: populateRecord

 /**
  * @param BaseActiveRecord $record
  * @param array $row
  */
 public static function populateRecord($record, $row)
 {
     // setup @class if not exists - required attribute
     if (is_array($row) && empty($row['@class'])) {
         Yii::info('Setup required empty @class(`' . $record::tableName() . '`) for record');
         $row['@class'] = $record::tableName();
     }
     BaseActiveRecord::populateRecord($record, $row);
 }
开发者ID:haiflive,项目名称:orientdb-yii2-connector,代码行数:13,代码来源:ActiveRecord.php

示例9: populateRecord

 /**
  * @inheritdoc
  *
  * @param ActiveRecord $record the record to be populated. In most cases this will be an instance
  * created by [[instantiate()]] beforehand.
  * @param array $row attribute values (name => value)
  */
 public static function populateRecord($record, $row)
 {
     $attributes = [];
     //        if (isset($row['_source'])) {
     //            $attributes = $row['_source'];
     //        }
     //
     //		if (isset($row['fields'])) {
     //            // reset fields in case it is scalar value
     //            $arrayAttributes = $record->arrayAttributes();
     //            foreach($row['fields'] as $key => $value) {
     //                if (!isset($arrayAttributes[$key]) && count($value) == 1) {
     //                    $row['fields'][$key] = reset($value);
     //                }
     //            }
     //            $attributes = array_merge($attributes, $row['fields']);
     //        }
     $attributes = $row;
     // just a plain document returned as array from query
     parent::populateRecord($record, $attributes);
     $pk = static::primaryKey()[0];
     //TODO should always set ID in case of fields are not returned
     if ($pk === '_id') {
         $record->_id = $row['_id'];
     }
     //        $record->_highlight = isset($row['highlight']) ? $row['highlight'] : null;
     //        $record->_score = isset($row['_score']) ? $row['_score'] : null;
     $record->_attachments = isset($row['_attachments']) ? $row['_attachments'] : [];
     $record->_rev = isset($row['_rev']) ? $row['_rev'] : null;
     // TODO version should always be available...
 }
开发者ID:squio,项目名称:yii2-cloudant,代码行数:38,代码来源:ActiveRecord.php

示例10: populateRecord

 public static function populateRecord($record, $row)
 {
     $attributes = [];
     if (!empty($row)) {
         $arrayAttributes = $record->arrayAttributes();
         foreach ($row as $key => $value) {
             if (!isset($arrayAttributes[$key])) {
                 $row[$key] = $value;
             }
         }
         $attributes = array_merge($attributes, $row);
     }
     parent::populateRecord($record, $attributes);
     $pk = static::primaryKey()[0];
     if ($pk === 'objectId') {
         $record->_id = $row['objectId'];
     }
 }
开发者ID:MiladAlshomary,项目名称:yii2-parse,代码行数:18,代码来源:ActiveRecord.php


注:本文中的yii\db\BaseActiveRecord::populateRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。