本文整理汇总了PHP中odbc_execute函数的典型用法代码示例。如果您正苦于以下问题:PHP odbc_execute函数的具体用法?PHP odbc_execute怎么用?PHP odbc_execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了odbc_execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSF
/**
* PHP Template.
*/
function updateSF($tableName, $rowID, $sfID)
{
$odbc = odbcConnect();
$stmt = odbc_prepare($odbc, "INSERT into SalesForceUpdateQueue (creationDate, mysqlTableName, mysqlRowID, salesForceID) VALUES(CURRENT_TIMESTAMP(), ?, ?, ?)");
$rs = odbc_execute($stmt, array($tableName, $rowID, $sfID));
odbc_close($odbc);
}
示例2: insert_id
public function insert_id($insertSql)
{
$query = odbc_execute($this->dbConnection(), $insertSql);
if ($query) {
return $query;
} else {
$this->halt('Database query error', $insertSql);
}
}
示例3: _exec
protected function _exec($sql, $params = array())
{
$this->_stmt = odbc_prepare($this->_con, $sql);
if ($this->_stmt === false) {
$this->raiseError($this->_stmt, $params);
}
$res = odbc_execute($this->_stmt, $params);
if ($res === false) {
$this->raiseError($sql, $params);
}
return $res;
}
示例4: exec
/**
* Executes the supplied SQL statement and returns
* the result of the call.
*
* @access public
*
* @param string SQL to execute
*/
function exec()
{
if (func_num_args() > 1) {
$args = func_get_args();
$sql = $args[0];
unset($args[0]);
// remove the sql
$args = array_values($args);
// and reset the array index
} else {
$sql = func_get_arg(0);
}
$this->ensureConnection();
if (isset($args)) {
$result = odbc_prepare($this->connection, $sql);
if (!odbc_execute($result, $args)) {
throw new Exception(odbc_errormsg($this->connection));
}
return odbc_num_rows($result);
} else {
return odbc_exec($this->connection, $sql);
}
}
示例5: _execute
/**
* Internal function to call native ODBC prepare/execute functions.
*/
protected function _execute($sql, $params, $fetchmode, $isupdate)
{
// Set any params passed directly
if ($params) {
for ($i = 0, $cnt = count($params); $i < $cnt; $i++) {
$this->set($i + 1, $params[$i]);
}
}
// Trim surrounding quotes added from default set methods.
// Exception: for LOB-based parameters, odbc_execute() will
// accept a filename surrounded by single-quotes.
foreach ($this->boundInVars as $idx => $var) {
if ($var instanceof Lob) {
$file = $isupdate ? $var->getInputFile() : $var->getOutputFile();
$this->boundInVars[$idx] = "'{$file}'";
} else {
if (is_string($var)) {
$this->boundInVars[$idx] = trim($var, "\"\\'");
}
}
}
if ($this->resultSet) {
$this->resultSet->close();
$this->resultSet = null;
}
$this->updateCount = null;
$stmt = @odbc_prepare($this->conn->getResource(), $sql);
if ($stmt === FALSE) {
throw new SQLException('Could not prepare query', $this->conn->nativeError(), $sql);
}
$ret = @odbc_execute($stmt, $this->boundInVars);
if ($ret === FALSE) {
@odbc_free_result($stmt);
throw new SQLException('Could not execute query', $this->conn->nativeError(), $sql);
}
return $this->conn->createResultSet(new ODBCResultResource($stmt), $fetchmode);
}
示例6: get_report
function get_report(client $client, $table_name, $show, $rownum)
{
if ($table_name == null) {
return "Bad table name.";
}
//TODO check table_name is one word
//compile query
$colnames = odbc_exec($client->get_connection(), "SELECT column_name, data_type, data_length FROM ALL_TAB_COLUMNS WHERE table_name = '" . strtoupper($table_name) . "';");
if ($colnames === false) {
return "Unable to get table fields.";
}
$query = "SELECT ";
$i = 0;
while (odbc_fetch_row($colnames)) {
if (isset($show) && isset($show[$i]) && $show[$i] == true) {
if ($query != "SELECT ") {
$query .= ", ";
}
$query .= odbc_result($colnames, 1);
}
$i += 1;
}
$query .= " FROM " . $table_name . " WHERE rownum <= ?;";
//prepare statement
$statement = odbc_prepare($client->get_connection(), $query);
if ($statement === false) {
return $query . "\n\n" . get_odbc_error();
}
$items = array();
$items[] = (int) $rownum;
$result = odbc_execute($statement, $items);
if ($result === false) {
return $query . "\n\n" . get_odbc_error();
}
return $statement;
}
示例7: DoQuery
function DoQuery($query, $first = 0, $limit = 0, $prepared_query = 0)
{
if ($prepared_query && isset($this->query_parameters[$prepared_query]) && count($this->query_parameters[$prepared_query])) {
if ($result = @odbc_prepare($this->connection, $query)) {
if (!@odbc_execute($result, $this->query_parameters[$prepared_query])) {
$this->SetODBCError("Do query", "Could not execute a ODBC database prepared query \"{$query}\"", $php_errormsg);
odbc_free_result($result);
return 0;
}
} else {
$this->SetODBCError("Do query", "Could not execute a ODBC database prepared query \"{$query}\"", $php_errormsg);
return 0;
}
} else {
$result = @odbc_exec($this->connection, $query);
}
if ($result) {
$this->current_row[$result] = -1;
if (substr(strtolower(ltrim($query)), 0, strlen("select")) == "select") {
$result_value = intval($result);
$this->current_row[$result_value] = -1;
if ($limit > 0) {
$this->limits[$result_value] = array($first, $limit, 0);
}
$this->highest_fetched_row[$result_value] = -1;
} else {
$this->affected_rows = odbc_num_rows($result);
odbc_free_result($result);
}
} else {
$this->SetODBCError("Do query", "Could not execute a ODBC database query \"{$query}\"", $php_errormsg);
}
return $result;
}
示例8: getPropertyAnnotations
/**
* Returns the mappings for the given template
* The result has the form Map<String, List<PropertyAnnotation>>
*
*/
private function getPropertyAnnotations($templateId)
{
Timer::start('LiveMappingBasedExtractor::getPropertyAnnotations');
$query = "SELECT " . "name, renamedValue, parseHint, isIgnored " . "FROM " . TBLPROPERTYANNOTATION . " a Join " . TBLPROPERTYMAPPING . " b On (a.id = b.parent_id) " . "WHERE " . "a.parent_id = ?";
$this->log(DEBUG, str_replace('?', $templateId . ";", $query));
$stmt = $this->odbc->prepare($query, get_class($this));
odbc_execute($stmt, array($templateId));
$result = array();
while (odbc_fetch_row($stmt)) {
$name = odbc_result($stmt, "name");
$parseHint = odbc_result($stmt, "parseHint");
$renamedValue = odbc_result($stmt, "renamedValue");
$isIgnored = odbc_result($stmt, "isIgnored");
$pa = null;
if (!array_key_exists($name, $result)) {
$pa = new PropertyAnnotation($name, $isIgnored);
$result[$name] = $pa;
} else {
$pa = $result[$name];
}
$pm = new PropertyMapping($renamedValue, $parseHint);
$pa->addMapping($pm);
}
Timer::stop('LiveMappingBasedExtractor::getPropertyAnnotations');
return $result;
}
示例9: query
/**
* Execute an sql query
*/
public function query($query, array $params = null)
{
# If the next query should be cached then run the cache function instead
if ($this->cacheNext) {
$this->cacheNext = false;
return $this->cache($query, $params);
}
# Ensure we have a connection to run this query on
$this->connect();
$this->query = $query;
$this->params = null;
$this->preparedQuery = false;
if (is_array($params)) {
$this->params = $params;
}
$this->quoteChars($query);
$this->functions($query);
$this->limit($query);
$this->tableNames($query);
$this->namedParams($query, $params);
$this->paramArrays($query, $params);
$this->convertNulls($params);
$preparedQuery = $this->prepareQuery($query, $params);
$this->preparedQuery = $preparedQuery;
if ($this->output) {
if ($this->htmlMode) {
echo "<pre>";
}
echo $preparedQuery;
if ($this->htmlMode) {
echo "<hr>";
} else {
echo "\n";
}
}
switch ($this->mode) {
case "mysql":
if (!($result = $this->server->query($preparedQuery))) {
$this->error();
}
break;
case "postgres":
case "redshift":
$tmpQuery = $query;
$query = "";
$noParams = false;
if ($this->mode == "redshift" && count($params) > 32767) {
$noParams = true;
}
$i = 1;
reset($params);
while ($pos = strpos($tmpQuery, "?")) {
if ($noParams) {
$query .= substr($tmpQuery, 0, $pos) . "'" . pg_escape_string(current($params)) . "'";
next($params);
} else {
$query .= substr($tmpQuery, 0, $pos) . "\$" . $i++;
}
$tmpQuery = substr($tmpQuery, $pos + 1);
}
$query .= $tmpQuery;
$params = Helper::toArray($params);
if (!($result = pg_query_params($this->server, $query, $params))) {
$this->error();
}
break;
case "odbc":
if (!($result = odbc_prepare($this->server, $query))) {
$this->error();
}
$params = Helper::toArray($params);
if (!odbc_execute($result, $params)) {
$this->error();
}
break;
case "sqlite":
if (!is_array($params)) {
if (!($result = $this->server->query($preparedQuery))) {
$this->error();
}
# If we have some parameters then we must convert them to the sqlite format
} else {
$newQuery = "";
foreach ($params as $key => $val) {
$pos = strpos($query, "?");
$newQuery .= substr($query, 0, $pos);
$query = substr($query, $pos + 1);
$newQuery .= ":var" . $key;
}
$newQuery .= $query;
if (!($result = $this->server->prepare($newQuery))) {
$this->error();
}
foreach ($params as $key => $val) {
switch (gettype($val)) {
case "boolean":
case "integer":
//.........这里部分代码省略.........
示例10: _query
function _query($sql, $inputarr = false)
{
global $php_errormsg;
if (isset($php_errormsg)) {
$php_errormsg = '';
}
$this->_error = '';
if ($inputarr) {
if (is_array($sql)) {
$stmtid = $sql[1];
} else {
$stmtid = odbc_prepare($this->_connectionID, $sql);
if ($stmtid == false) {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
return false;
}
}
if (!odbc_execute($stmtid, $inputarr)) {
//@odbc_free_result($stmtid);
if ($this->_haserrorfunctions) {
$this->_errorMsg = odbc_errormsg();
$this->_errorCode = odbc_error();
}
if ($this->_errorCode == '00000') {
// MS SQL Server sometimes returns this in combination with the FreeTDS
$this->_errorMsg = '';
// driver and UnixODBC under Linux. This fixes the bogus "error"
$this->_errorCode = 0;
// <karsten@typo3.org>
return true;
}
return false;
}
} else {
if (is_array($sql)) {
$stmtid = $sql[1];
if (!odbc_execute($stmtid)) {
//@odbc_free_result($stmtid);
if ($this->_haserrorfunctions) {
$this->_errorMsg = odbc_errormsg();
$this->_errorCode = odbc_error();
}
if ($this->_errorCode == '00000') {
// MS SQL Server sometimes returns this in combination with the FreeTDS
$this->_errorMsg = '';
// driver and UnixODBC under Linux. This fixes the bogus "error"
$this->_errorCode = 0;
// <karsten@typo3.org>
return true;
}
return false;
}
} else {
$stmtid = odbc_exec($this->_connectionID, $sql);
}
}
$this->_lastAffectedRows = 0;
if ($stmtid) {
if (@odbc_num_fields($stmtid) == 0) {
$this->_lastAffectedRows = odbc_num_rows($stmtid);
$stmtid = true;
} else {
$this->_lastAffectedRows = 0;
odbc_binmode($stmtid, $this->binmode);
odbc_longreadlen($stmtid, $this->maxblobsize);
}
if ($this->_haserrorfunctions) {
$this->_errorMsg = '';
$this->_errorCode = 0;
} else {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
} else {
if ($this->_haserrorfunctions) {
$this->_errorMsg = odbc_errormsg();
$this->_errorCode = odbc_error();
} else {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
}
return $stmtid;
}
示例11: With
}
# With (default) debug mode, the following statements will generate
# annoying "cursor updatability" warnings.
$rv = odbc_execute($stmt, array(2, 'two'));
if ($rv != 1) {
exit("2nd Insertion failed with value {$rv}\n");
}
$rv = odbc_execute($stmt, array(3, 'three'));
if ($rv != 1) {
exit("3rd Insertion failed with value {$rv}\n");
}
$rv = odbc_execute($stmt, array(4, 'four'));
if ($rv != 1) {
exit("4th Insertion failed with value {$rv}\n");
}
$rv = odbc_execute($stmt, array(5, 'five'));
if ($rv != 1) {
exit("5th Insertion failed with value {$rv}\n");
}
odbc_commit($conn_id);
# A non-parameterized query
$rs = odbc_exec($conn_id, "SELECT * FROM tsttbl WHERE id < 3");
if (!$rs) {
exit("Error in SQL\n");
}
$rownum = 0;
while (odbc_fetch_row($rs)) {
$rownum++;
echo "{$rownum}: " . odbc_result($rs, "id") . '|' . odbc_result($rs, "vc") . '|' . odbc_result($rs, "entrytime") . "\n";
}
# You need to use the PDO_ODBC extension to parameterize queries (selects).
示例12: _query
function _query($sql, $inputarr = false)
{
global $php_errormsg;
$php_errormsg = '';
$this->_error = '';
if ($inputarr) {
if (is_resource($sql)) {
$stmtid = $sql;
} else {
$stmtid = odbc_prepare($this->_connectionID, $sql);
}
if ($stmtid == false) {
$this->_errorMsg = $php_errormsg;
return false;
}
//print_r($inputarr);
if (!odbc_execute($stmtid, $inputarr)) {
@odbc_free_result($stmtid);
return false;
}
} else {
$stmtid = odbc_exec($this->_connectionID, $sql);
}
if ($stmtid) {
odbc_binmode($stmtid, $this->binmode);
odbc_longreadlen($stmtid, $this->maxblobsize);
}
$this->_errorMsg = $php_errormsg;
return $stmtid;
}
示例13: executeUnbufferedQuery
/**
* Executes the statement in unbuffered mode (if possible)
*
* @internal
*
* @param fUnbufferedResult $result The object to place the result into
* @param array $params The parameters for the statement
* @param mixed &$extra A variable to place extra information needed by some database extensions
* @param boolean $different If this statement is different than the last statement run on the fDatabase instance
* @return void
*/
public function executeUnbufferedQuery($result, $params, &$extra, $different)
{
if ($different && $this->used) {
$this->regenerateStatement();
}
$this->used = TRUE;
$extension = $this->database->getExtension();
$connection = $this->database->getConnection();
$statement = $this->statement;
$params = $this->prepareParams($params);
// For the extensions that require the statement be passed to the result
// object, we store it in a stdClass object so the result object knows
// not to free it when done
$statement_holder = new stdClass();
$statement_holder->statement = NULL;
switch ($extension) {
case 'ibm_db2':
$extra = $statement;
if (db2_execute($statement, $params)) {
$statement_holder->statement = $statement;
} else {
$result->setResult(FALSE);
}
break;
case 'mssql':
$result->setResult(mssql_query($result->getSQL(), $this->connection, 20));
break;
case 'mysql':
$result->setResult(mysql_unbuffered_query($result->getSQL(), $this->connection));
break;
case 'mysqli':
$extra = $this->statement;
if ($statement->execute()) {
$statement_holder->statement = $statement;
} else {
$result->setResult(FALSE);
}
break;
case 'oci8':
$result->setResult(oci_execute($statement, $this->database->isInsideTransaction() ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS));
break;
case 'odbc':
$extra = odbc_execute($statement, $params);
if ($extra) {
odbc_longreadlen($statement, 1048576);
odbc_binmode($statement, ODBC_BINMODE_CONVERT);
$statement_holder->statement = $statement;
} else {
$result->setResult($extra);
}
break;
case 'pgsql':
$result->setResult(pg_execute($connection, $this->identifier, $params));
break;
case 'sqlite':
$result->setResult(sqlite_unbuffered_query($connection, $this->database->escape($statement, $params), SQLITE_ASSOC, $extra));
break;
case 'sqlsrv':
$extra = sqlsrv_execute($statement);
if ($extra) {
$statement_holder->statement = $statement;
} else {
$result->setResult($extra);
}
break;
case 'pdo':
$extra = $statement->execute();
if ($extra) {
$result->setResult($statement);
} else {
$result->setResult($extra);
}
break;
}
if ($statement_holder->statement) {
$result->setResult($statement_holder);
}
return $result;
}
示例14: _odbc_ttlp_execute
private function _odbc_ttlp_execute($ntriples, $graphURI)
{
$odbc_result = false;
if (Options::getOption('dryRun')) {
$virtuosoPl = "DB.DBA.TTLP_MT (\n'{$ntriples}', '{$graphURI}', '{$graphURI}', 255)";
$this->log(INFO, $virtuosoPl);
$odbc_result = true;
} else {
$virtuosoPl = "DB.DBA.TTLP_MT (?, '{$graphURI}', '{$graphURI}', 255)";
$stmt = $this->odbc->prepare($virtuosoPl, 'LiveUpdateDestination');
$odbc_result = odbc_execute($stmt, array($ntriples));
if ($odbc_result == false) {
$this->log(ERROR, 'ttlp insert failes');
$this->log(ERROR, $virtuosoPl);
$this->log(ERROR, substr(odbc_errormsg(), 0, 100));
$this->log(ERROR, substr($ntriples, 0, 100));
} else {
$this->log(INFO, 'insert returned a true via odbc_execute');
}
//old line, now we use odbc_prepare
//$result = $this->odbc->exec( $virtuosoPl,'LiveUpdateDestination');
$this->counterTotalODBCOperations += 1;
$this->log(TRACE, $virtuosoPl);
}
return $odbc_result;
}
示例15: deleteFromODBC
function deleteFromODBC($sql, $params)
{
$results = odbc_prepare($this->conn, $sql);
if ($results === false) {
// throw new ErrorException(odbc_errormsg());
return false;
}
if (odbc_execute($results, $params) === false) {
return false;
//throw new ErrorException(odbc_errormsg());
}
return $results;
}