Example #1
0
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (mosDBTable::delete($oid)) {
         $query = "DELETE FROM #__poll_data" . "\n WHERE pollid = " . (int) $this->{$k};
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         $query = "DELETE FROM #__poll_date" . "\n WHERE poll_id = " . (int) $this->{$k};
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         $query = "DELETE from #__poll_menu" . "\n WHERE pollid = " . (int) $this->{$k};
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 /**
  *	binds an array/hash to this object
  *	@param int $oid optional argument, if not specifed then the value of current key is used
  *	@return any result from the database operation
  */
 function load($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid !== null) {
         $this->{$k} = $oid;
     }
     $oid = $this->{$k};
     if ($oid === null) {
         return false;
     }
     //BB fix : resets default values to all object variables, because NULL SQL fields do not overide existing variables !
     //Note: Prior to PHP 4.2.0, Uninitialized class variables will not be reported by get_class_vars().
     $class_vars = get_class_vars(get_class($this));
     foreach ($class_vars as $name => $value) {
         if ($name != $k and $name != "_db" and $name != "_tbl" and $name != "_tbl_key") {
             $this->{$name} = $value;
         }
     }
     //end of BB fix.
     return parent::load($oid);
 }
Example #3
0
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (mosDBTable::delete($oid)) {
         $this->_db->setQuery("DELETE FROM #__poll_data WHERE pollid='" . $this->{$k} . "'");
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         $this->_db->setQuery("DELETE FROM #__poll_date WHERE pollid='" . $this->{$k} . "'");
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         $this->_db->setQuery("DELETE from #__poll_menu where pollid='" . $this->{$k} . "'");
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         return true;
     } else {
         return false;
     }
 }
Example #4
0
 function load($cid = 0)
 {
     if ($cid == 0) {
         // Only read if recID passed
         return $this->init_record();
     } else {
         // fill in some 'null' fields
         return parent::load($cid);
     }
 }
Example #5
0
 /**
  * Converts record to XML
  * @param boolean Map foreign keys to text values
  */
 function toXML($mapKeysToText = false)
 {
     global $database;
     if ($mapKeysToText) {
         $query = 'SELECT name FROM #__sections WHERE id=' . $this->sectionid;
         $database->setQuery($query);
         $this->sectionid = $database->loadResult();
         $query = 'SELECT name FROM #__categories WHERE id=' . $this->catid;
         $database->setQuery($query);
         $this->catid = $database->loadResult();
         $query = 'SELECT name FROM #__users WHERE id=' . $this->created_by;
         $database->setQuery($query);
         $this->created_by = $database->loadResult();
     }
     return parent::toXML($mapKeysToText);
 }