本文整理汇总了PHP中ADOConnection::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP ADOConnection::execute方法的具体用法?PHP ADOConnection::execute怎么用?PHP ADOConnection::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADOConnection
的用法示例。
在下文中一共展示了ADOConnection::execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: queryDb
/**
* 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;
}
示例2: _setUp
/**
* 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 . '"');
}
}