53 public function &
create($isNew =
true)
62 public function &
get($id)
67 $sql =
'SELECT * FROM '.$this->db->prefix(
'tplset').
' WHERE tplset_id='.$id;
68 if ($result = $this->db->query($sql)) {
69 $numrows = $this->db->getRowsNum($result);
72 $tplset->assignVars($this->db->fetchArray($result));
80 public function &getByName($tplset_name)
83 $tplset_name = trim($tplset_name);
84 if (
'' != $tplset_name) {
85 $sql =
'SELECT * FROM '.$this->db->prefix(
'tplset').
' WHERE tplset_name='.$this->db->quoteString($tplset_name);
86 if ($result = $this->db->query($sql)) {
87 $numrows = $this->db->getRowsNum($result);
90 $tplset->assignVars($this->db->fetchArray($result));
102 $tplset_credits =
null;
103 $tplset_created =
null;
105 if (
'xoopstplset' != strtolower(get_class($tplset))) {
108 if (!$tplset->isDirty()) {
111 if (!$tplset->cleanVars()) {
114 foreach ($tplset->cleanVars as $k => $v) {
117 if ($tplset->isNew()) {
118 $tplset_id = $this->db->genId(
'tplset_tplset_id_seq');
119 $sql = sprintf(
'INSERT INTO %s (tplset_id, tplset_name, tplset_desc, tplset_credits, tplset_created) VALUES (%u, %s, %s, %s, %u)', $this->db->prefix(
'tplset'), $tplset_id, $this->db->quoteString($tplset_name), $this->db->quoteString($tplset_desc), $this->db->quoteString($tplset_credits), $tplset_created);
121 $sql = sprintf(
'UPDATE %s SET tplset_name = %s, tplset_desc = %s, tplset_credits = %s, tplset_created = %u WHERE tplset_id = %u', $this->db->prefix(
'tplset'), $this->db->quoteString($tplset_name), $this->db->quoteString($tplset_desc), $this->db->quoteString($tplset_credits), $tplset_created, $tplset_id);
123 if (!$result = $this->db->query($sql)) {
126 if (empty($tplset_id)) {
127 $tplset_id = $this->db->getInsertId();
129 $tplset->assignVar(
'tplset_id', $tplset_id);
133 public function delete(&$tplset)
135 if (
'xoopstplset' != strtolower(get_class($tplset))) {
138 $sql = sprintf(
'DELETE FROM %s WHERE tplset_id = %u', $this->db->prefix(
'tplset'), $tplset->getVar(
'tplset_id'));
139 if (!$result = $this->db->query($sql)) {
142 $sql = sprintf(
'DELETE FROM %s WHERE tplset_name = %s', $this->db->prefix(
'imgset_tplset_link'), $this->db->quoteString($tplset->getVar(
'tplset_name')));
143 $this->db->query($sql);
147 public function &getObjects($criteria =
null, $id_as_key =
false)
151 $sql =
'SELECT * FROM '.$this->db->prefix(
'tplset');
152 if (isset($criteria) && $criteria instanceof \criteriaelement) {
153 $sql .=
' '.$criteria->renderWhere().
' ORDER BY tplset_id';
154 $limit = $criteria->getLimit();
155 $start = $criteria->getStart();
157 $result = $this->db->query($sql, $limit, $start);
161 while ($myrow = $this->db->fetchArray($result)) {
162 $tplset =
new XoopsTplset();
163 $tplset->assignVars($myrow);
167 $ret[$myrow[
'tplset_id']] =& $tplset;
175 public function getCount($criteria =
null)
177 $sql =
'SELECT COUNT(*) FROM '.$this->db->prefix(
'tplset');
178 if (isset($criteria) && $criteria instanceof \criteriaelement) {
179 $sql .=
' '.$criteria->renderWhere();
181 if (!$result =& $this->db->query($sql)) {
184 [$count] = $this->db->fetchRow($result);
188 public function &getList($criteria =
null)
191 $tplsets =& $this->getObjects($criteria,
true);
192 foreach ($tplsets as $tpl) {
193 $name = $tpl->getVar(
'tplset_name');