/** * Method to provide a shortcut to binding, checking and storing a JTable * instance to the database table. The method will check a row in once the * data has been stored and if an ordering filter is present will attempt to * reorder the table rows based on the filter. The ordering filter is an instance * property name. The rows that will be reordered are those whose value matches * the JTable instance for the property specified. * * @param mixed $src An associative array or object to bind to the JTable instance. * @param string $orderingFilter Filter for the order updating * @param mixed $ignore An optional array or space separated list of properties * to ignore while binding. * * @return boolean True on success. * * @link http://docs.joomla.org/JTable/save * @since 11.1 */ public function save($src, $orderingFilter = '', $ignore = '') { // Attempt to bind the source to the instance. if (!$this->bind($src, $ignore)) { return false; } // Run any sanity checks on the instance and verify that it is ready for storage. if (!$this->check()) { return false; } // Attempt to store the properties to the database table. if (!$this->store()) { return false; } // Attempt to check the row in, just in case it was checked out. if (!$this->checkin()) { return false; } // If an ordering filter is set, attempt reorder the rows in the table based on the filter and value. if ($orderingFilter) { $filterValue = $this->{$orderingFilter}; $this->reorder($orderingFilter ? $this->_db->quoteName($orderingFilter) . ' = ' . $this->_db->Quote($filterValue) : ''); } // Set the error to empty and return true. $this->setError(''); return true; }
/** * Inserts $message to the currently open database. Calls open(), * if necessary. Also passes the message along to any Log_observer * instances that are observing this Log. * * @param mixed $message String or object containing the message to log. * @param string $priority The priority of the message. Valid * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = null) { /* If a priority hasn't been specified, use the default value. */ if ($priority === null) { $priority = $this->_priority; } /* Abort early if the priority is above the maximum logging level. */ if (!$this->_isMasked($priority)) { return false; } /* If the connection isn't open and can't be opened, return failure. */ if (!$this->_opened && !$this->open()) { return false; } /* Extract the string representation of the message. */ $message = $this->_extractMessage($message); /* Build the SQL query for this log entry insertion. */ $q = sprintf('insert into %s (logtime, ident, priority, message)' . 'values(%s, %s, %d, %s)', $this->_table, $this->_db->DBTimeStamp(time()), $this->_db->Quote($this->_ident), $priority, $this->_db->Quote($message)); $result = $this->_db->Execute($q); if ($this->_db->ErrorMsg() != '') { return false; } $this->_announce(array('priority' => $priority, 'message' => $message)); return true; }
public function UpdateLevelById($category_id, $level, $level_name) { $category_id = $this->db->Quote($category_id); $level = $this->db->Quote($level); $level_name = $this->db->Quote($level_name); $sql = 'UPDATE ' . _DB_PREFIX_ . 'category_tags SET tag_level_name = ' . $level_name . ' WHERE tag_level = ' . $level . ' AND id_category = ' . $category_id; $this->db->StartTrans(); if ($this->db->Execute($sql)) { $this->db->CompleteTrans(); return true; } else { $this->db->FailTrans(); return false; } }
/** * Get user information from database * * This function uses the given username to fetch * the corresponding login data from the database * table. If an account that matches the passed username * and password is found, the function returns true. * Otherwise it returns false. * * @param string Username * @param string Password * @return mixed Error object or boolean */ function fetchData($username, $password) { // Prepare for a database query $err = $this->_prepare(); if ($err !== true) { return PEAR::raiseError($err->getMessage(), $err->getCode()); } // Find if db_fields contains a *, i so assume all col are selected if (strstr($this->options['db_fields'], '*')) { $sql_from = "*"; } else { $sql_from = $this->options['usernamecol'] . ", " . $this->options['passwordcol'] . $this->options['db_fields']; } $query = "SELECT " . $sql_from . " FROM " . $this->options['table'] . " WHERE " . $this->options['usernamecol'] . " = " . $this->db->Quote($username); $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $rset = $this->db->Execute($query); $res = $rset->fetchRow(); if (DB::isError($res)) { return PEAR::raiseError($res->getMessage(), $res->getCode()); } if (!is_array($res)) { $this->activeUser = ''; return false; } if ($this->verifyPassword(trim($password, "\r\n"), trim($res[$this->options['passwordcol']], "\r\n"), $this->options['cryptType'])) { // Store additional field values in the session foreach ($res as $key => $value) { if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) { continue; } // Use reference to the auth object if exists // This is because the auth session variable can change so a static call to setAuthData does not make sence if (is_object($this->_auth_obj)) { $this->_auth_obj->setAuthData($key, $value); } else { Auth::setAuthData($key, $value); } } return true; } $this->activeUser = $res[$this->options['usernamecol']]; return false; }