Esempio n. 1
0
 /**
  * Load some modules
  *
  * @param CriteriaElement|null $criteria  criteria to match
  * @param boolean              $id_as_key Use the ID as key into the array
  *
  * @return array
  */
 public function getObjectsArray(CriteriaElement $criteria = null, $id_as_key = false)
 {
     $ret = array();
     $qb = $this->db2->createXoopsQueryBuilder();
     $qb->select('*')->fromPrefix('system_module', null);
     if (isset($criteria) && $criteria instanceof CriteriaElement) {
         $criteria->setSort('weight');
         $criteria->renderQb($qb);
         $qb->addOrderBy('mid', 'ASC');
     }
     // During install, we start with no tables and no installed modules. We need to
     // handle the resulting exceptions and return an empty array.
     try {
         if (!($result = $qb->execute())) {
             return $ret;
         }
     } catch (\Doctrine\DBAL\Driver\PDOException $e) {
         return $ret;
     } catch (\Doctrine\DBAL\Exception\TableNotFoundException $e) {
         return $ret;
     } catch (\PDOException $e) {
         return $ret;
     }
     while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
         $module = new XoopsModule();
         $module->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] = $module;
         } else {
             $ret[$myrow['mid']] = $module;
         }
         unset($module);
     }
     return $ret;
 }
Esempio n. 2
0
 /**
  * Load some modules
  *
  * @param CriteriaElement|null $criteria  {@link CriteriaElement}
  * @param boolean              $id_as_key Use the ID as key into the array
  *
  * @return array
  */
 public function getObjectsArray(CriteriaElement $criteria = null, $id_as_key = false)
 {
     $ret = array();
     $qb = $this->db2->createXoopsQueryBuilder();
     $qb->select('*')->fromPrefix('modules', null);
     if (isset($criteria) && $criteria instanceof CriteriaElement) {
         $criteria->setSort('weight');
         $criteria->renderQb($qb);
         $qb->addOrderBy('mid', 'ASC');
     }
     try {
         if (!($result = $qb->execute())) {
             return $ret;
         }
     } catch (Exception $e) {
         return $ret;
     }
     while ($myrow = $result->fetch(PDO::FETCH_ASSOC)) {
         $module = new XoopsModule();
         $module->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] = $module;
         } else {
             $ret[$myrow['mid']] = $module;
         }
         unset($module);
     }
     return $ret;
 }