Ejemplo n.º 1
0
 function &get($id, $getsource = false)
 {
     $id = intval($id);
     if ($id > 0) {
         if (!$getsource) {
             $sql = 'SELECT * FROM ' . $this->db->prefix('tplfile') . ' WHERE tpl_id=' . $id;
         } else {
             $sql = 'SELECT f.*, s.tpl_source FROM ' . $this->db->prefix('tplfile') . ' f LEFT JOIN ' . $this->db->prefix('tplsource') . ' s  ON s.tpl_id=f.tpl_id WHERE f.tpl_id=' . $id;
         }
         if (!($result = $this->db->query($sql))) {
             return false;
         }
         $numrows = $this->db->getRowsNum($result);
         if ($numrows == 1) {
             $tplfile = new XoopsTplfile();
             $tplfile->assignVars($this->db->fetchArray($result));
             return $tplfile;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 function &getObjects($criteria = null, $getsource = false, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     if ($getsource) {
         $sql = 'SELECT f.*, s.tpl_source FROM ' . $this->db->prefix('tplfile') . ' f LEFT JOIN ' . $this->db->prefix('tplsource') . ' s ON s.tpl_id=f.tpl_id';
     } else {
         $sql = 'SELECT * FROM ' . $this->db->prefix('tplfile');
     }
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere() . ' ORDER BY tpl_refid';
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $tplfile = new XoopsTplfile();
         $tplfile->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $tplfile;
         } else {
             $ret[$myrow['tpl_id']] =& $tplfile;
         }
         unset($tplfile);
     }
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * getTplObjects
  *
  * @param CriteriaElement|null $criteria
  * @param bool                 $getsource
  * @param bool                 $id_as_key
  *
  * @return array
  */
 public function getTplObjects(CriteriaElement $criteria = null, $getsource = false, $id_as_key = false)
 {
     $qb = $this->db2->createXoopsQueryBuilder();
     $eb = $qb->expr();
     $ret = array();
     if (!$getsource) {
         $qb->select('*')->fromPrefix('tplfile', 'f');
     } else {
         $qb->select('f.*')->addSelect('s.tpl_source')->fromPrefix('tplfile', 'f')->leftJoinPrefix('f', 'tplsource', 's', $eb->eq('s.tpl_id', 'f.tpl_id'));
     }
     if (isset($criteria) && $criteria instanceof CriteriaElement) {
         $criteria->renderQb($qb);
     }
     $result = $qb->execute();
     if (!$result) {
         return $ret;
     }
     while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
         $tplfile = new XoopsTplfile();
         $tplfile->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] = $tplfile;
         } else {
             $ret[$myrow['tpl_id']] = $tplfile;
         }
         unset($tplfile);
     }
     return $ret;
 }