Advertisement
raul3k

grupo

Aug 15th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <?php
  2. require_once dirname(dirname(realpath(__FILE__))) . DIRECTORY_SEPARATOR . 'grupo' . DIRECTORY_SEPARATOR . 'grupo_table.php';
  3. /**
  4.  * Created by JetBrains PhpStorm.
  5.  * User: raul.silva
  6.  * Date: 14/08/12
  7.  * Time: 15:21
  8.  * To change this template use File | Settings | File Templates.
  9.  */
  10. class grupo extends grupo_table
  11. {
  12.     protected $filiais = array();
  13.  
  14.     public function __construct($id = null)
  15.     {
  16.         parent::__construct($id);
  17.     }
  18.  
  19.     public function getFiliais()
  20.     {
  21.         if( ! is_null($this->getId()))
  22.         {
  23.             require_once dirname(dirname(realpath(__FILE__))) . DIRECTORY_SEPARATOR . 'filial' . DIRECTORY_SEPARATOR . 'filial.php';
  24.             $this->db->select(filial_table::getIdFieldName())->from(filial_table::getTableName())->where($this->id_field, $this->getId());
  25.             $ids = $this->db->get()->result_array();
  26.             $filiais = array();
  27.             if(count($ids) > 0)
  28.             {
  29.                 foreach($ids as $id)
  30.                 {
  31.                     $filiais[] = new filial($id['id_jos_atc_filial']);
  32.                 }
  33.             }
  34.  
  35.             $this->filiais = $filiais;
  36.  
  37.  
  38.             return $filiais;
  39.         }
  40.  
  41.         return false;
  42.     }
  43.  
  44.     public function getGrupos()
  45.     {
  46.         $this->db->select($this->id_field)->from($this->table_name);
  47.         $ids = $this->db->get()->result_array();
  48.         $id_grupos = array();
  49.         foreach($ids as $id)
  50.         {
  51.             $id_grupos[] = new grupo($id['id_jos_atc_filial_grupo']);
  52.         }
  53.         return $id_grupos;
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement