Exemple #1
0
 /**
  * Get some {@link XoopsNotification}s
  *
  * @param   object  $criteria
  * @param   bool    $id_as_key  Use IDs as keys into the array?
  *
  * @return  array   Array of {@link XoopsNotification} objects
  **/
 function &getObjects($criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->db->prefix('xoopsnotifications');
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         $sort = $criteria->getSort() != '' ? $criteria->getSort() : 'not_id';
         $sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder();
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $notification = new XoopsNotification();
         $notification->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $notification;
         } else {
             $ret[$myrow['not_id']] =& $notification;
         }
         unset($notification);
     }
     return $ret;
 }
 /**
  * Update
  *
  * @param XoopsNotification $notification {@link XoopsNotification} object
  * @param string            $field_name   Name of the field
  * @param mixed             $field_value  Value to write
  *
  * @return bool
  **/
 public function updateByField(XoopsNotification $notification, $field_name, $field_value)
 {
     $notification->unsetNew();
     $notification->setVar($field_name, $field_value);
     return $this->insert($notification);
 }