當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。