/** * Sends the sql to the database and returns the results. * * @internal Switches between ADOConnection::Execute() and * ADOConnection::SelectLimit() depending on the $query parameter's * $solutionModifier "limit" and "offset" settings. * Uses $query variable. * * @param array $arSql Array that gets a SQL query string once imploded * * @return mixed Anything ADOConnection::Execute() may return * @throws Exception If Database query does not work */ function queryDb($arSql, $nOffset, $nLimit) { $strSql = SparqlEngineDb_SqlMerger::getSelect($this->query, $arSql); if ($strSql == '()') { return new ADORecordSet(false); } // I want associative arrays. $oldmode = $this->dbConn->SetFetchMode(ADODB_FETCH_ASSOC); if (isset($GLOBALS['debugSparql']) && $GLOBALS['debugSparql']) { echo 'SQL query: ' . $strSql . "\n"; } if ($nLimit === null && $nOffset == 0) { $ret = $this->dbConn->execute($strSql); } else { if ($nLimit === null) { $ret = $this->dbConn->SelectLimit($strSql, -1, $nOffset); } else { $ret = $this->dbConn->SelectLimit($strSql, $nLimit, $nOffset); } } //... but others maybe not $this->dbConn->SetFetchMode($oldmode); if (!$ret) { //Error occured throw new Exception('ADOdb error: ' . $this->dbConn->ErrorMsg() . "\n" . $strSql); } return $ret; }
/** * Setting up connection parameters - sql mode, encoding, logging etc * * @param ADOConnection $oDb database connection instance */ protected function _setUp($oDb) { $_iDebug = self::_getConfigParam('_iDebug'); if ($_iDebug == 2 || $_iDebug == 3 || $_iDebug == 4 || $_iDebug == 7) { try { $oDb->execute('truncate table adodb_logsql'); } catch (ADODB_Exception $e) { // nothing } if (method_exists($oDb, "logSQL")) { $oDb->logSQL(true); } } $oDb->cacheSecs = 60 * 10; // 10 minute caching $oDb->execute('SET @@session.sql_mode = ""'); if (self::_getConfigParam('_iUtfMode')) { $oDb->execute('SET NAMES "utf8"'); $oDb->execute('SET CHARACTER SET utf8'); $oDb->execute('SET CHARACTER_SET_CONNECTION = utf8'); $oDb->execute('SET CHARACTER_SET_DATABASE = utf8'); $oDb->execute('SET character_set_results = utf8'); $oDb->execute('SET character_set_server = utf8'); } elseif (($sConn = self::_getConfigParam('_sDefaultDatabaseConnection')) != '') { $oDb->execute('SET NAMES "' . $sConn . '"'); } }