本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: loadModel
/**
* @param \yii\db\ActiveRecord $model
*/
public function loadModel($model)
{
$this->attributes = $model->toArray();
}
示例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));
}
示例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;
}
示例7: toArray
public function toArray()
{
$array = parent::toArray();
$array['pingicon'] = $this->pingicon;
return $array;
}
示例8: toArray
public function toArray(array $fields = array(), array $expand = array(), $recursive = true)
{
$array = parent::toArray($fields, $expand, $recursive);
return $array;
}
示例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;
}
示例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;
}
示例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;
});
}
示例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;
}
示例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);
}
}
}
示例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);
}