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


PHP ActiveRecord::toArray方法代码示例

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


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

示例1: getRoles

 public function getRoles($originalSorting = false)
 {
     $uid = $this->id;
     if (!$uid) {
         return [$this->role];
     }
     ## get roles
     $roles = Role::model()->with('userRoles')->findAll(ActiveRecord::formatCriteria(['condition' => '|user_id| = :p', 'order' => '|is_default_role|', 'params' => [':p' => $uid]]));
     $roles = ActiveRecord::toArray($roles);
     if (empty($roles)) {
         return false;
     }
     $idx = 0;
     foreach ($roles as $k => $role) {
         ## find current role index
         if ($role['role_name'] == Yii::app()->user->getState('role') && $idx == 0) {
             $idx = $k;
         }
     }
     if ($originalSorting) {
         return $roles;
     }
     $role = array_splice($roles, $idx, 1);
     array_unshift($roles, $role[0]);
     $this->roles = $roles;
     return $roles;
 }
开发者ID:rizabudi,项目名称:plansys,代码行数:27,代码来源:User.php

示例2: afterSave

 public function afterSave()
 {
     parent::doAfterSave(false);
     ## get assign user id to user roles
     $ur = $this->userRoles;
     foreach ($ur as $k => $u) {
         $ur[$k]['user_id'] = $this->id;
     }
     $olduser = ActiveRecord::toArray($this->getRelated('userRoles'));
     ActiveRecord::batch('UserRole', $ur, $olduser);
     ## re-subscribe user to notification
     if (!$this->isNewRecord) {
         Yii::app()->nfy->unsubscribe($this->id, null, true);
     }
     if ($this->subscribed === "on" || $this->subscribed === "ON" || $this->isNewRecord) {
         $roles = array();
         $sql = 'select DISTINCT role_name from p_user_role p ' . ' inner join p_role r on p.role_id = r.id ' . ' and p.user_id = ' . $this->id;
         $db = Yii::app()->db->createCommand($sql)->queryAll();
         foreach ($db as $r) {
             if ($this->subscriptionCategories === 'EMPTY' || in_array($r['role_name'], $this->subscriptionCategories)) {
                 $roles[] = "role_" . $r['role_name'] . ".";
             }
         }
         $category = array_merge(array('uid_' . $this->id), $roles);
         Yii::app()->nfy->subscribe($this->id, $this->username, $category);
         $this->subscribed = true;
     } else {
         $this->subscribed = false;
     }
     return true;
 }
开发者ID:balitax,项目名称:plansys,代码行数:31,代码来源:User.php

示例3: afterSave

 public function afterSave()
 {
     parent::doAfterSave(false);
     ## get assign user id to user roles
     $ur = $this->userRoles;
     foreach ($ur as $k => $u) {
         $ur[$k]['user_id'] = $this->id;
     }
     $olduser = ActiveRecord::toArray($this->getRelated('userRoles'));
     ActiveRecord::batch('UserRole', $ur, $olduser);
     return true;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:12,代码来源:User.php

示例4: getList

 public function getList()
 {
     $models = Todo::model()->findAllByAttributes(['user_id' => Yii::app()->user->id], ['order' => 'id desc']);
     $array = ActiveRecord::toArray($models);
     foreach ($array as $k => $a) {
         foreach ($a as $i => $j) {
             if (is_array($j)) {
                 unset($array[$k][$i]);
             }
         }
     }
     return $array;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:13,代码来源:TodoWidget.php

示例5: toArray

 public function toArray($force = false)
 {
     $array = parent::toArray($force);
     try {
         self::executePlugins($array, 'array', get_class($this));
     } catch (Exception $e) {
         die($e->getMessage() . ' (' . __LINE__);
     }
     if ($this->specificationInstance && $this->specificationInstance instanceof EavSpecificationManager && (empty($array['attributes']) || $force)) {
         $array['attributes'] = $this->specificationInstance->toArray();
         EavSpecificationManager::sortAttributesByHandle('EavSpecificationManager', $array);
     }
     return $array;
 }
开发者ID:saiber,项目名称:www,代码行数:14,代码来源:ActiveRecordModel.php

示例6: toArray

 public function toArray($force = false)
 {
     $array = parent::toArray($force);
     self::executePlugins($array, 'array', get_class($this));
     if ($this->specificationInstance && $this->specificationInstance instanceof EavSpecificationManager && (empty($array['attributes']) || $force)) {
         $array['attributes'] = $this->specificationInstance->toArray();
         EavSpecificationManager::sortAttributesByHandle('EavSpecificationManager', $array);
     }
     return $array;
 }
开发者ID:GregerA,项目名称:livecart,代码行数:10,代码来源:ActiveRecordModel.php


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