本文整理汇总了PHP中odbc_longreadlen函数的典型用法代码示例。如果您正苦于以下问题:PHP odbc_longreadlen函数的具体用法?PHP odbc_longreadlen怎么用?PHP odbc_longreadlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了odbc_longreadlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
function query($Query_String)
{
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "") {
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new DB_Sql_Subclass;'
*/
return 0;
}
$this->connect();
# printf("<br>Debug: query = %s<br>\n", $Query_String);
# rei@netone.com.br suggested that we use this instead of the odbc_do().
# He is on NT, connecting to a Unix MySQL server with ODBC. -- KK
# $this->Query_ID = odbc_prepare($this->Link_ID,$Query_String);
# $this->Query_Ok = odbc_execute($this->Query_ID);
$this->Query_ID = odbc_do($this->Link_ID, $Query_String);
$this->Row = 0;
odbc_binmode($this->Query_ID, 1);
odbc_longreadlen($this->Query_ID, 4096);
if (!$this->Query_ID) {
$this->Errno = 1;
$this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
$this->halt("Invalid SQL: " . $Query_String);
}
return $this->Query_ID;
}
示例2: execAsJson
public function execAsJson($query, $logComponent)
{
$query = 'sparql define output:format "RDF/XML" ' . $query;
/*
$query= 'sparql define output:format "TTL" ' .$query;
*/
/*
echo $query;
die;
*/
$odbc_result = $this->exec($query, $logComponent);
odbc_longreadlen($odbc_result, ODBC_MAX_LONGREAD_LENGTH);
odbc_fetch_row($odbc_result);
$data = false;
do {
$temp = odbc_result($odbc_result, 1);
if ($temp != null) {
$data .= $temp;
}
} while ($temp != null);
//=$data;
$conv = new XmlConverter();
$arr = $conv->toArray($data);
//print_r($arr);
//die;
//Logger::warn('check if faster with default graph, ');
return $arr;
}
示例3: query
function query($Query_String)
{
// remove the 'LIMIT' clause from the query
$pos = strpos($Query_String, " LIMIT ");
if ($pos) {
$Query_String = substr($Query_String, 0, $pos);
}
unset($pos);
$this->connect();
# printf("<br />Debug: query = %s<br />\n", $Query_String);
# rei@netone.com.br suggested that we use this instead of the odbc_exec().
# He is on NT, connecting to a Unix MySQL server with ODBC. -- KK
# $this->Query_ID = odbc_prepare($this->Link_ID,$Query_String);
# $this->Query_Ok = odbc_execute($this->Query_ID);
$this->Query_ID = odbc_exec($this->Link_ID, $Query_String);
$this->Row = 0;
odbc_binmode($this->Query_ID, 1);
odbc_longreadlen($this->Query_ID, 4096);
if (!$this->Query_ID) {
$this->Errno = 1;
$this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
$this->halt("Invalid SQL: " . $Query_String);
}
return $this->Query_ID;
}
示例4: query
/**
* Send an SQL query
* @param String sql
* @return Mixed
*/
public function query($sql)
{
$this->debugInfo($sql);
$rs = odbc_exec($this->conn, $sql);
if (!$rs) {
trigger_error(odbc_error(), E_USER_ERROR);
return FALSE;
}
odbc_binmode($rs, ODBC_BINMODE_RETURN);
odbc_longreadlen($rs, 1024 * 1024);
return new QueryResult($this, $rs);
}
示例5: db_query
function db_query($qstring,$conn)
{
global $strLastSQL,$dDebug;
if ($dDebug===true)
echo $qstring."<br>";
$strLastSQL=$qstring;
if(!($rs=odbc_exec($conn,$qstring)))
trigger_error(odbc_error(), E_USER_ERROR);
odbc_binmode($rs,ODBC_BINMODE_RETURN);
odbc_longreadlen($rs,1024*1024);
return $rs;
}
示例6: _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();
}
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();
}
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;
}
示例7: _getContents
/**
* Get file contents
*
* @param string $path file path
* @return string|false
* @author Dmitry (dio) Levashov
**/
protected function _getContents($path)
{
$sql = "SET TEXTSIZE 2147483647 ";
// increase mssql or odbc data size limit
$sql .= sprintf('SELECT convert(varbinary(max),content) as content FROM %s WHERE id=%d', $this->tbf, $path);
$res = $this->query($sql);
odbc_binmode($res, ODBC_BINMODE_RETURN);
//long binary handling
odbc_longreadlen($res, 500000000);
//increase mssql or odbc data size 500 Megabytes
$r = odbc_fetch_array($res);
return $res && $r ? base64_decode($r['content']) : false;
}
示例8: readLobData
/**
* Reads in any unread LOB data. For long char fields, we may already
* have up to odbc_longreadlen() bytes in the buffer. These are passed
* in via the $curdata parm. For long binary fields, no data is read
* initially since odbc_binmode() is set to ODBC_BINMODE_PASSTHRU.
* This method adjusts the binmode and longreadlen to finish reading
* these datatypes into the buffer. Returns a string with the complete
* contents.
*
* @param int|string $column Column index or name to read data from.
* @param int $binmode ODBC_BINMODE_RETURN for binary data, ODBC_BINMODE_CONVERT for char data.
* @param string $curdata Existing LOB data already in buffer.
* @return string
*/
protected function readLobData($column, $binmode, $curdata = null)
{
// Retrieve field num
$fldNum = is_int($column) ? $column : getFieldNum($column);
$data = $curdata;
$newdata = null;
// Adjust binmode and longreadlen
odbc_binmode($this->result->getHandle(), $binmode);
odbc_longreadlen($this->result->getHandle(), 4096);
while (1) {
$newdata = odbc_result($this->result->getHandle(), $fldNum);
if ($newdata === false) {
break;
} else {
$data .= $newdata;
}
}
// Restore the default binmode and longreadlen
odbc_binmode($this->result->getHandle(), ODBC_BINMODE_PASSTHRU);
odbc_longreadlen($this->result->getHandle(), ini_get('odbc.defaultlrl'));
// The ODBC driver I use seems to return a string with an escaped
// null char at the end for clob data.
$data = rtrim($data, "");
return $data;
}
示例9: _retrieveHashValues
private function _retrieveHashValues()
{
$sql = 'Select ' . FIELD_JSON_BLOB . '
From ' . TABLENAME . '
Where ' . FIELD_OAIID . ' = ' . $this->oaiId;
$odbc_result = $this->odbc->exec($sql, 'Hash::_retrieveHashValues');
$num = odbc_num_rows($odbc_result);
if ($num <= 0) {
$this->log(INFO, $this->subject . ' : no hash found');
return false;
}
odbc_longreadlen($odbc_result, ODBC_MAX_LONGREAD_LENGTH);
odbc_fetch_row($odbc_result);
$data = false;
do {
$temp = odbc_result($odbc_result, 1);
if ($temp != null) {
$data .= $temp;
}
} while ($temp != null);
$this->hashesFromStore = json_decode($data, true);
if (!is_array($this->hashesFromStore)) {
$this->log(WARN, 'conversion to JSON failed, not using hash this time');
$this->log(WARN, $data);
return false;
}
$this->log(INFO, $this->subject . ' retrieved hashes from ' . count(array_keys($this->hashesFromStore)) . ' extractors ');
return true;
}
示例10: executeQuery
/**
* Executes an SQL query
*
* @param fResult $result The result object for the query
* @return void
*/
private function executeQuery($result)
{
// We don't want errors and an exception
$old_level = error_reporting(error_reporting() & ~E_WARNING);
if ($this->extension == 'mssql') {
$result->setResult(mssql_query($result->getSQL(), $this->connection));
} elseif ($this->extension == 'mysql') {
$result->setResult(mysql_query($result->getSQL(), $this->connection));
} elseif ($this->extension == 'mysqli') {
$result->setResult(mysqli_query($this->connection, $result->getSQL()));
} elseif ($this->extension == 'oci8') {
$oci_statement = oci_parse($this->connection, $result->getSQL());
if (oci_execute($oci_statement, $this->inside_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS)) {
oci_fetch_all($oci_statement, $rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
$result->setResult($rows);
unset($rows);
} else {
$result->setResult(FALSE);
}
} elseif ($this->extension == 'odbc') {
$resource = odbc_exec($this->connection, $result->getSQL());
if (is_resource($resource)) {
$rows = array();
// Allow up to 1MB of binary data
odbc_longreadlen($resource, 1048576);
odbc_binmode($resource, ODBC_BINMODE_CONVERT);
while ($row = odbc_fetch_array($resource)) {
$rows[] = $row;
}
$result->setResult($rows);
unset($rows);
} else {
$result->setResult($resource);
}
} elseif ($this->extension == 'pgsql') {
$result->setResult(pg_query($this->connection, $result->getSQL()));
} elseif ($this->extension == 'sqlite') {
$result->setResult(sqlite_query($this->connection, $result->getSQL(), SQLITE_ASSOC, $sqlite_error_message));
} elseif ($this->extension == 'sqlsrv') {
$resource = sqlsrv_query($this->connection, $result->getSQL());
if (is_resource($resource)) {
$rows = array();
while ($row = sqlsrv_fetch_array($resource, SQLSRV_FETCH_ASSOC)) {
$rows[] = $row;
}
$result->setResult($rows);
unset($rows);
} else {
$result->setResult($resource);
}
} elseif ($this->extension == 'pdo') {
if (preg_match('#^\\s*CREATE(\\s+OR\\s+REPLACE)?\\s+TRIGGER#i', $result->getSQL())) {
$this->connection->exec($result->getSQL());
$pdo_statement = FALSE;
$returned_rows = array();
} else {
$pdo_statement = $this->connection->query($result->getSQL());
$returned_rows = is_object($pdo_statement) ? $pdo_statement->fetchAll(PDO::FETCH_ASSOC) : $pdo_statement;
// The pdo_pgsql driver likes to return empty rows equal to the number of affected rows for insert and deletes
if ($this->type == 'postgresql' && $returned_rows && $returned_rows[0] == array()) {
$returned_rows = array();
}
}
$result->setResult($returned_rows);
}
error_reporting($old_level);
if ($this->extension == 'sqlite') {
$this->checkForError($result, $sqlite_error_message);
} elseif ($this->extension == 'oci8') {
$this->checkForError($result, $oci_statement);
} else {
$this->checkForError($result);
}
if ($this->extension == 'pdo') {
$this->setAffectedRows($result, $pdo_statement);
if ($pdo_statement) {
$pdo_statement->closeCursor();
}
unset($pdo_statement);
} elseif ($this->extension == 'oci8') {
$this->setAffectedRows($result, $oci_statement);
oci_free_statement($oci_statement);
} elseif ($this->extension == 'odbc') {
$this->setAffectedRows($result, $resource);
odbc_free_result($resource);
} elseif ($this->extension == 'sqlsrv') {
$this->setAffectedRows($result, $resource);
sqlsrv_free_stmt($resource);
} else {
$this->setAffectedRows($result);
}
$this->setReturnedRows($result);
$this->handleAutoIncrementedValue($result);
}
示例11: _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;
}
示例12: performUnbufferedQuery
/**
* Executes an unbuffered SQL query
*
* @param string|fStatement $statement The statement to perform
* @param fUnbufferedResult $result The result object for the query
* @param array $params The parameters for prepared statements
* @return void
*/
private function performUnbufferedQuery($statement, $result, $params)
{
$this->setErrorHandler();
$extra = NULL;
if (is_object($statement)) {
$statement->executeUnbufferedQuery($result, $params, $extra, $statement != $this->statement);
} elseif ($this->extension == 'ibm_db2') {
$result->setResult(db2_exec($this->connection, $statement, array('cursor' => DB2_FORWARD_ONLY)));
} elseif ($this->extension == 'mssql') {
$result->setResult(mssql_query($result->getSQL(), $this->connection, 20));
} elseif ($this->extension == 'mysql') {
$result->setResult(mysql_unbuffered_query($result->getSQL(), $this->connection));
} elseif ($this->extension == 'mysqli') {
$result->setResult(mysqli_query($this->connection, $result->getSQL(), MYSQLI_USE_RESULT));
} elseif ($this->extension == 'oci8') {
$extra = oci_parse($this->connection, $result->getSQL());
if (oci_execute($extra, $this->inside_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS)) {
$result->setResult($extra);
} else {
$result->setResult(FALSE);
}
} elseif ($this->extension == 'odbc') {
$extra = odbc_exec($this->connection, $result->getSQL());
if ($extra) {
odbc_longreadlen($extra, 1048576);
odbc_binmode($extra, ODBC_BINMODE_CONVERT);
}
$result->setResult($extra);
} elseif ($this->extension == 'pgsql') {
$result->setResult(pg_query($this->connection, $result->getSQL()));
} elseif ($this->extension == 'sqlite') {
$result->setResult(sqlite_unbuffered_query($this->connection, $result->getSQL(), SQLITE_ASSOC, $extra));
} elseif ($this->extension == 'sqlsrv') {
$result->setResult(sqlsrv_query($this->connection, $result->getSQL()));
} elseif ($this->extension == 'pdo') {
$result->setResult($this->connection->query($result->getSQL()));
}
$this->statement = $statement;
$this->restoreErrorHandler();
$this->checkForError($result, $extra);
}
示例13: _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;
}
示例14: connect
/**
* @see Connection::connect()
*/
public function connect($dsninfo, $flags = 0)
{
if (!function_exists('odbc_connect')) {
throw new SQLException('odbc extension not loaded');
}
$adapterclass = isset($dsninfo['adapter']) ? $dsninfo['adapter'] : null;
if (!$adapterclass) {
$adapterclass = 'ODBCAdapter';
} else {
$adapterclass .= 'Adapter';
}
Creole::import('creole.drivers.odbc.adapters.' . $adapterclass);
$this->adapter = new $adapterclass();
$this->dsn = $dsninfo;
$this->flags = $flags;
if (!($this->flags & Creole::COMPAT_ASSOC_LOWER) && !$this->adapter->preservesColumnCase()) {
trigger_error('Connection created without Creole::COMPAT_ASSOC_LOWER, ' . 'but driver does not support case preservation.', E_USER_WARNING);
$this->flags != Creole::COMPAT_ASSOC_LOWER;
}
$persistent = ($flags & Creole::PERSISTENT) === Creole::PERSISTENT;
if ($dsninfo['database']) {
$odbcdsn = $dsninfo['database'];
} elseif ($dsninfo['hostspec']) {
$odbcdsn = $dsninfo['hostspec'];
} else {
$odbcdsn = 'localhost';
}
$user = @$dsninfo['username'];
$pw = @$dsninfo['password'];
$connect_function = $persistent ? 'odbc_pconnect' : 'odbc_connect';
$conn = @$connect_function($odbcdsn, $user, $pw, SQL_CUR_USE_IF_NEEDED);
if (!is_resource($conn)) {
throw new SQLException('connect failed', $this->nativeError(), $odbcdsn);
}
$this->dblink = $conn;
/**
* This prevents blob fields from being fetched when a row is loaded
* from a recordset. Clob fields however are loaded with up to
* 'odbc.defaultlrl' data. This should be the default anyway, but we'll
* set it here just to keep things consistent.
*/
@odbc_binmode(0, ODBC_BINMODE_PASSTHRU);
@odbc_longreadlen(0, ini_get('odbc.defaultlrl'));
}
示例15: odbc_binmode
<?php
if ($conn = odbc_connect($dsn, $dbuser, $dbpwd)) {
if ($res = odbc_do($conn, "select gif from php_test where id='{$id}'")) {
odbc_binmode($res, 0);
odbc_longreadlen($res, 0);
if (odbc_fetch_row($res)) {
header("content-type: image/gif");
odbc_result($res, 1);
exit;
} else {
echo "Error in odbc_fetch_row";
}
} else {
echo "Error in odbc_do";
}
} else {
echo "Error in odbc_connect";
}