/** * Enter description here... * * @param string $sql * @param int $limit * @param int $start * @return boolean */ function &_query($sql, $limit = 0, $start = 0) { if (!($result =& $this->_db->query($sql, $limit, $start))) { $this->_error = $this->_db->error(); $result = false; } return $result; }
/** * Checks to see if table exists * * @param string $table name of database table looking for * * @return bool true if exists or false if doesnt */ public function tableExists($table) { $table = trim($table); $ret = false; if ($table != '') { $this->db->connect(); $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix($table); $ret = false != $this->db->query($sql) ? true : false; } return $ret; }
/** * Assign a value to 1 field for tickets matching a set of conditions * * @param string $fieldname * @param string $fieldvalue * @param object $criteria {@link CriteriaElement} * * @return bool FALSE if update failed * @access public */ public function updateAll($fieldname, $fieldvalue, $criteria = null) { $set_clause = is_numeric($fieldvalue) ? $fieldname . ' = ' . $fieldvalue : $fieldname . ' = ' . $this->_db->quoteString($fieldvalue); $sql = 'UPDATE ' . $this->_db->prefix($this->_dbtable) . ' SET ' . $set_clause; if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere(); } if (!($result = $this->_db->query($sql))) { return false; } return true; }
/** * execute an SQL statement * * @param string $sql SQL statement to execute * @param bool $force true to use queryF * * @return mixed result resouce if no error, * true if no error but no result * false if error encountered. * Any error message is in $this->lastError; */ private function &execSql($sql, $force = false) { if ($force) { $result = $this->db->queryF($sql); } else { $result = $this->db->query($sql); } if (!$result) { $this->lastError = $this->db->error(); $this->lastErrNo = $this->db->errno(); } return $result; }
/** * @param XoopsDatabase $db * @param $table * @param $field * @param string $condition * * @return bool */ function getDbValue(XoopsDatabase $db, $table, $field, $condition = '') { $table = $db->prefix($table); $sql = "SELECT `{$field}` FROM `{$table}`"; if ($condition) { $sql .= " WHERE {$condition}"; } $result = $db->query($sql); if ($result) { $row = $db->fetchRow($result); if ($row) { return $row[0]; } } return false; }