public function listCompanyBranchsByUserProfile($id_user, $id_profile, $isActive = NULL)
 {
     $select_company_branch = $this->buildSelectFields('cb_', 'cb', 'company_branch');
     $sql = '
         SELECT
             ' . $select_company_branch . '
         FROM
             "' . $this->table . '" AS "upcb"
             INNER JOIN "user_profile" AS "up" ON "up"."id" = "upcb"."id_user_profile"
             INNER JOIN "profile" AS "p" ON "p"."id" = "up"."id_profile"
             INNER JOIN "user" AS "u" ON "u"."id" = "up"."id_user"
             INNER JOIN "company_branch" AS "cb" ON "cb"."id" = "upcb"."id_company_branch"
         WHERE 1=1
             AND "p"."id" = ' . $this->db->escape($id_profile) . '
             AND "u"."id" = ' . $this->db->escape($id_user) . '
             ' . (is_null($isActive) ? '' : " AND \"cb\".\"isActive\"='" . $isActive . "'") . '
     ';
     $query = $this->db->query($sql);
     if ($query === FALSE) {
         Helper_Log::write($this->messageError(__FUNCTION__, FALSE), Helper_Log::LOG_DB);
         throw new Exception("Problema ejecución en Base de Datos, ver log de errores. Consulte con Sistemas");
     }
     $rows = $query->result_array();
     $eCompanyBranches = array();
     if (!empty($rows)) {
         foreach ($rows as $row) {
             $eCompanyBranch = new eCompanyBranch();
             $eCompanyBranch->parseRow($row, 'cb_');
             $eCompanyBranches[] = $eCompanyBranch;
         }
     }
     return $eCompanyBranches;
 }
 function filter(filterCompanyBranch $filter, &$eCompanyBranches, &$count = NULL)
 {
     $eCompanyBranches = array();
     $count = 0;
     $queryR = $this->db->query($this->filterQuery($filter));
     if ($queryR === FALSE) {
         Helper_Log::write($this->messageError(__FUNCTION__, FALSE), Helper_Log::LOG_DB);
         throw new Exception("Problema ejecución en Base de Datos, ver log de errores. Consulte con Sistemas");
     }
     $queryC = $this->db->query($this->filterQuery($filter, TRUE));
     if ($queryC === FALSE) {
         Helper_Log::write($this->messageError(__FUNCTION__, FALSE), Helper_Log::LOG_DB);
         throw new Exception("Problema ejecución en Base de Datos, ver log de errores. Consulte con Sistemas");
     }
     $row = $queryC->row_array();
     $count = $row['count'];
     $rows = $queryR->result_array();
     if (!empty($rows)) {
         foreach ($rows as $row) {
             $eCompanyBranch = new eCompanyBranch();
             $eCompanyBranch->parseRow($row, 'cb_');
             $eCompanyBranches[] = $eCompanyBranch;
         }
     }
 }