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


PHP ActiveRecord::toArray方法代码示例

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


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

示例1: toArray

 public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
 {
     $array = parent::toArray($fields, $expand, $recursive);
     if (strpos($array['photo_base64'], 'uploads') !== false && strpos($array['photo_base64'], 'http:') === false) {
         $array['photo_base64'] = Yii::$app->request->getHostInfo() . $array['photo_base64'];
     }
     return $array;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:8,代码来源:Studio.php

示例2: toArray

 public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
 {
     $array = parent::toArray($fields, $expand, $recursive);
     $array['likes'] = $this->getLikes()->all();
     $array['created'] = date("d M Y", $this->created_at);
     if (strpos($array['image_base64'], 'uploads') !== false && strpos($array['image_base64'], 'http:') === false) {
         $array['image_base64'] = Yii::$app->request->getHostInfo() . $array['image_base64'];
     }
     return $array;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:10,代码来源:Gallery.php

示例3: toArray

 public function toArray(array $fields = [], array $expand = [], $recursive = true)
 {
     $data = parent::toArray($fields, $expand, $recursive);
     $data['id'] = strtoupper(bin2hex($data['id']));
     foreach ($this->uuidRelations as $relationKey) {
         if (isset($data[$relationKey])) {
             $data[$relationKey] = strtoupper(bin2hex($data[$relationKey]));
         }
     }
     return $data;
 }
开发者ID:wartron,项目名称:yii2-uuid,代码行数:11,代码来源:ActiveRecord.php

示例4: loadModel

 /**
  * @param \yii\db\ActiveRecord $model
  */
 public function loadModel($model)
 {
     $this->attributes = $model->toArray();
 }
开发者ID:gromver,项目名称:yii2-platform,代码行数:7,代码来源:ActiveDocument.php

示例5: toArray

 public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
 {
     $array = parent::toArray($fields, $expand, $recursive);
     unset($array['user_auth_key']);
     unset($array['user_password_hash']);
     unset($array['user_password_reset_token']);
     unset($array['stream_userid']);
     unset($array['stream_username']);
     unset($array['stream_password']);
     return array_merge($array, $this->getUserInfo($this->id));
 }
开发者ID:pylypen,项目名称:admin-side,代码行数:11,代码来源:Users.php

示例6: toArray

 /**
  * @param array $fields
  * @param array $expand
  * @param bool|true $recursive
  * @return array
  */
 public function toArray(array $fields = [], array $expand = [], $recursive = true)
 {
     if (empty($fields)) {
         $fields = $this->fields();
     }
     $fields = array_diff($fields, $this->hidden);
     $data = parent::toArray(ArrayHelper::valuesToUnderscore($fields), $expand, $recursive);
     ArrayHelper::keysToCamelCase($data);
     return $data;
 }
开发者ID:JiltImageBoard,项目名称:jilt-backend,代码行数:16,代码来源:ARExtended.php

示例7: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $array['pingicon'] = $this->pingicon;
     return $array;
 }
开发者ID:RyosukeMurai,项目名称:TokyoSearch,代码行数:6,代码来源:Instagram.php

示例8: toArray

 public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
 {
     $array = parent::toArray($fields, $expand, $recursive);
     return $array;
 }
开发者ID:pylypen,项目名称:admin-side,代码行数:5,代码来源:Classes.php

示例9: toArray

 /**
  * Adds _label field to serialized array if model has a __toString() method.
  *
  * @inheritdoc
  */
 public function toArray(array $fields = [], array $expand = [], $recursive = true)
 {
     $data = parent::toArray($fields, $expand, $recursive);
     if (method_exists($this, '__toString')) {
         $data['_label'] = $this->__toString();
     }
     return $data;
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:13,代码来源:ActiveRecord.php

示例10: toArray

 public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
 {
     $array = parent::toArray($fields, $expand, $recursive);
     unset($array['user_auth_key']);
     unset($array['user_password_hash']);
     unset($array['user_password_reset_token']);
     return $array;
 }
开发者ID:pylypen,项目名称:admin-side,代码行数:8,代码来源:User.php

示例11: toArray

 /**
  * Redefine standard toArray method for avoiding showing atributes with null value
  * null attributes needed for exended view of many-to-many relation
  * @param array $fields
  * @param array $expand
  * @param bool|true $recursive
  * @return array
  */
 public function toArray(array $fields = [], array $expand = [], $recursive = true)
 {
     return array_filter(parent::toArray($fields, $expand, $recursive), function ($val) {
         return is_null($val) ? false : true;
     });
 }
开发者ID:AndriyK,项目名称:team,代码行数:14,代码来源:AppActiveRecord.php

示例12: toArray

 public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
 {
     $array = parent::toArray($fields, $expand, $recursive);
     if (!empty($array['students'])) {
         foreach ($array['students'] as $k => $v) {
             if (strpos($array['students'][$k]['payment_image'], 'uploads') !== false && strpos($array['students'][$k]['payment_image'], 'http:') === false) {
                 $array['students'][$k]['payment_image'] = Yii::$app->request->getHostInfo() . $array['students'][$k]['payment_image'];
             }
         }
     }
     return $array;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:12,代码来源:Classes.php

示例13: addRowToMap

 /**
  * Add a one row to identity map
  * @param ActiveRecord | array $row
  */
 public static function addRowToMap($row)
 {
     $id = static::getIdAttribute();
     if ($row !== null && isset($row[$id])) {
         self::$identityMap[$row[$id]] = $row instanceof ActiveRecord ? $row->toArray() : $row;
         $maxSize = static::getIdentityMapMaxSize();
         foreach (static::getUniqueAttributes() as $uniqueAttribute) {
             self::$uniqueAttributeToId[$uniqueAttribute][$row[$uniqueAttribute]] = $row[$id];
         }
         if ($maxSize !== -1 && count(self::$identityMap) > $maxSize) {
             array_shift(self::$identityMap);
         }
     }
 }
开发者ID:yiister,项目名称:yii2-mappable-ar,代码行数:18,代码来源:ActiveRecordTrait.php

示例14: toArray

 /**
  * (non-PHPdoc)
  * @see \yii\base\Model::toArray()
  */
 public function toArray(array $fields = [], array $expand = [], $recursive = true)
 {
     if ($this->getIsNewRecord() && $this->applyDefaults && !$this->defaultsApplied) {
         $this->applyDefaults(false);
     }
     $recursive = false;
     return parent::toArray($fields, $expand, $recursive);
 }
开发者ID:fangface,项目名称:yii2-concord,代码行数:12,代码来源:ActiveRecord.php


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