Advertisement
salientdigital

KO3 ORM within a Foreach Loop

Dec 27th, 2010
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1.     public function action_placements()
  2.     {
  3.         if($this->user->has('roles', ORM::factory('role', array('name' => 'admin'))))
  4.         {
  5.             $adplacements = ORM::factory('adplacement')
  6.                 ->find_all();
  7.         }
  8.         else
  9.         {
  10.             $adplacements = ORM::factory('adplacement')
  11.                 ->where('user_id','=',$this->user->id)
  12.                 ->find_all();
  13.         }
  14.         $placements = array();
  15.         foreach($adplacements as $ap)
  16.         {
  17.             $adlocation = $ap->adlocation;
  18.             $adunit     = $ap->adunit;
  19.             $row = array(
  20.                 'id'        =>  $ap->id,
  21.                 'website'   =>  $ap->website ,
  22.                 'location'  =>  $adlocation->label ,
  23.                 'adunit'    =>  $adunit->label ,
  24.             );
  25.             $placements[] = $row;
  26.         }
  27.        $data = array(
  28.             'placements' => $placements ,
  29.        );
  30.        $this->template->content = view::factory('admin/publisher/list',$data);
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement