function &get($id) { $ret = false; $id = intval($id); if ($id > 0) { $sql = 'SELECT * FROM ' . $this->db->prefix('tplset') . ' WHERE tplset_id=' . $id; if ($result = $this->db->query($sql)) { $numrows = $this->db->getRowsNum($result); if ($numrows == 1) { $tplset = new XoopsTplset(); $tplset->assignVars($this->db->fetchArray($result)); $ret =& $tplset; } } } return $ret; }
function &getObjects($criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('tplset'); if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere() . ' ORDER BY tplset_id'; $limit = $criteria->getLimit(); $start = $criteria->getStart(); } $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { $tplset = new XoopsTplset(); $tplset->assignVars($myrow); if (!$id_as_key) { $ret[] =& $tplset; } else { $ret[$myrow['tplset_id']] =& $tplset; } unset($tplset); } return $ret; }
/** * getByName * * @param string $tplset_name of the block to retrieve * * @return XoopsTplset|false reference to the tplsets */ public function getByName($tplset_name) { $qb = $this->db2->createXoopsQueryBuilder(); $eb = $qb->expr(); $tplset = false; $tplset_name = trim($tplset_name); if ($tplset_name != '') { $qb->select('*')->fromPrefix('tplset', null)->where($eb->eq('tplset_name', ':tplsetname'))->setParameter(':tplsetname', $tplset_name, \PDO::PARAM_STR); $result = $qb->execute(); if (!$result) { return false; } $allrows = $result->fetchAll(); if (count($allrows) == 1) { $tplset = new XoopsTplset(); $tplset->assignVars(reset($allrows)); } } return $tplset; }