本文整理汇总了PHP中db2_free_result函数的典型用法代码示例。如果您正苦于以下问题:PHP db2_free_result函数的具体用法?PHP db2_free_result怎么用?PHP db2_free_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db2_free_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: free
/**
* This function frees the command reference.
*
* @access public
* @override
*
* @see http://www.php.net/manual/en/function.db2-free-result.php
*/
public function free()
{
if ($this->command !== NULL) {
@db2_free_result($this->command);
$this->command = NULL;
$this->record = FALSE;
}
}
示例2: closeCursor
/**
* {@inheritdoc}
*/
public function closeCursor()
{
if (!$this->_stmt) {
return false;
}
$this->_bindParam = array();
db2_free_result($this->_stmt);
$ret = db2_free_stmt($this->_stmt);
$this->_stmt = false;
return $ret;
}
示例3: disConnect
/**
* {@inheritdoc}
*/
public function disConnect()
{
if ($this->result) {
db2_free_result($this->result);
}
if (is_resource($this->connection)) {
$this->connected = !db2_close($this->connection);
} else {
$this->connected = false;
}
return !$this->connected;
}
示例4: otherdb
//.........这里部分代码省略.........
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td>' . "{$db2row[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
\tStr[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
\tStr[3] = "input 'D:\\createtable.sql';";
\tStr[4] = "shell netstat -an;";
fbform.fbsql.value = Str[i];
return true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">����sql</option>
\t<option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($fbaction == 'fbquery') {
$fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
$fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
echo '<td><b>' . ibase_field_info($fbresult, $i) . "</b></td>\n";
}
echo "</tr>\n";
ibase_field_info($fbresult, 0);
while ($fbrow = ibase_fetch_row($fbresult)) {
echo "<tr>\n";
for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
echo '<td>' . "{$fbrow[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
ibase_free_result($fbresult);
ibase_close();
}
}
}
示例5: performQuery
//.........这里部分代码省略.........
$extra = oci_parse($this->connection, $result->getSQL());
if ($extra && oci_execute($extra, $this->inside_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS)) {
oci_fetch_all($extra, $rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
$result->setResult($rows);
unset($rows);
} else {
$result->setResult(FALSE);
}
} 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, $extra));
} elseif ($this->extension == 'sqlsrv') {
$extra = sqlsrv_query($this->connection, $result->getSQL());
if (is_resource($extra)) {
$rows = array();
while ($row = sqlsrv_fetch_array($extra, SQLSRV_FETCH_ASSOC)) {
$rows[] = $row;
}
$result->setResult($rows);
unset($rows);
} else {
$result->setResult($extra);
}
} elseif ($this->extension == 'pdo') {
if (preg_match('#^\\s*CREATE(\\s+OR\\s+REPLACE)?\\s+TRIGGER#i', $result->getSQL())) {
$this->connection->exec($result->getSQL());
$extra = FALSE;
$returned_rows = array();
} else {
$extra = $this->connection->query($result->getSQL());
if (is_object($extra)) {
// This fixes a segfault issue with blobs and fetchAll() for pdo_ibm
if ($this->type == 'db2') {
$returned_rows = array();
while (($row = $extra->fetch(PDO::FETCH_ASSOC)) !== FALSE) {
foreach ($row as $key => $value) {
if (is_resource($value)) {
$row[$key] = stream_get_contents($value);
}
}
$returned_rows[] = $row;
}
// pdo_dblib doesn't throw an exception on error when executing
// a prepared statement when compiled against FreeTDS, so we have
// to manually check the error info to see if something went wrong
} elseif ($this->type == 'mssql' && !fCore::checkOS('windows') && preg_match('#^\\s*EXEC(UTE)?\\s+#i', $result->getSQL())) {
$error_info = $extra->errorInfo();
if ($error_info && strpos($error_info[2], '(null) [0] (severity 0)') !== 0) {
$returned_rows = FALSE;
}
} else {
$returned_rows = $extra->fetchAll(PDO::FETCH_ASSOC);
}
} else {
$returned_rows = $extra;
}
// 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);
}
$this->statement = $statement;
$this->handleErrors(fCore::stopErrorCapture());
// The mssql extension will sometimes not return FALSE even if there are errors
if (strlen($this->error) && strpos($this->error, 'WARNING!') !== 0) {
$result->setResult(FALSE);
}
$this->checkForError($result, $extra);
if ($this->extension == 'mssql') {
$this->error = '';
}
if ($this->extension == 'ibm_db2') {
$this->setAffectedRows($result, $extra);
if ($extra && !is_object($statement)) {
db2_free_result($extra);
}
} elseif ($this->extension == 'pdo') {
$this->setAffectedRows($result, $extra);
if ($extra && !is_object($statement)) {
$extra->closeCursor();
}
} elseif ($this->extension == 'oci8') {
$this->setAffectedRows($result, $extra);
if ($extra && !is_object($statement)) {
oci_free_statement($extra);
}
} elseif ($this->extension == 'sqlsrv') {
$this->setAffectedRows($result, $extra);
if ($extra && !is_object($statement)) {
sqlsrv_free_stmt($extra);
}
} else {
$this->setAffectedRows($result, $extra);
}
$this->setReturnedRows($result);
$this->handleAutoIncrementedValue($result, $extra);
}
示例6: disconnect
/**
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
*/
function disconnect()
{
@db2_free_result($this->results);
$this->connected = !@db2_close($this->connection);
return !$this->connected;
}
示例7: freeResult
/**
* Frees memory associated with a statement resource
* @param $res Object: statement resource to free
* @return Boolean success or failure
*/
public function freeResult($res)
{
if ($res instanceof ResultWrapper) {
$res = $res->result;
}
if (!@db2_free_result($res)) {
throw new DBUnexpectedError($this, "Unable to free DB2 result\n");
}
}
示例8: freeResult
/**
* Frees memory associated with a statement resource
* @param $res Object: statement resource to free
* @throws DBUnexpectedError
* @return Boolean success or failure
*/
public function freeResult($res)
{
if ($res instanceof ResultWrapper) {
$res = $res->result;
}
wfSuppressWarnings();
$ok = db2_free_result($res);
wfRestoreWarnings();
if (!$ok) {
throw new DBUnexpectedError($this, "Unable to free DB2 result\n");
}
}
示例9: dbi_free_result
/**
* Frees a result set.
*
* @param resource $res The database query resource returned from
* the {@link dbi_query()} function.
*
* @return bool True on success
*/
function dbi_free_result($res)
{
if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
return mysql_free_result($res);
} else {
if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
return mysqli_free_result($res);
} else {
if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
return mssql_free_result($res);
} else {
if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
// Not supported. Ingore.
if ($GLOBALS["oracle_statement"] >= 0) {
OCIFreeStatement($GLOBALS["oracle_statement"]);
$GLOBALS["oracle_statement"] = -1;
}
} else {
if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
return pg_freeresult($res);
} else {
if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
return odbc_free_result($res);
} else {
if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
return db2_free_result($res);
} else {
if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
return ibase_free_result($res);
} else {
dbi_fatal_error("dbi_free_result(): db_type not defined.");
}
}
}
}
}
}
}
}
}
示例10: closeQuery
/**
* Free resources associated with a query result set
* @param Mixed qHanle The query handle
*/
public function closeQuery($qHanle)
{
@db2_free_result($qHanle);
}
示例11: DBfetch
/**
* Returns the next data set from a DB resource or false if there are no more results.
*
* @param resource $cursor
* @param bool $convertNulls convert all null values to string zeroes
*
* @return array|bool
*/
function DBfetch($cursor, $convertNulls = true)
{
global $DB;
$result = false;
if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) {
return $result;
}
switch ($DB['TYPE']) {
case ZBX_DB_MYSQL:
$result = mysqli_fetch_assoc($cursor);
if (!$result) {
mysqli_free_result($cursor);
}
break;
case ZBX_DB_POSTGRESQL:
if (!($result = pg_fetch_assoc($cursor))) {
pg_free_result($cursor);
}
break;
case ZBX_DB_ORACLE:
if ($row = oci_fetch_assoc($cursor)) {
$result = array();
foreach ($row as $key => $value) {
$field_type = strtolower(oci_field_type($cursor, $key));
// Oracle does not support NULL values for string fields, so if the string is empty, it will return NULL
// convert it to an empty string to be consistent with other databases
$value = str_in_array($field_type, array('varchar', 'varchar2', 'blob', 'clob')) && is_null($value) ? '' : $value;
if (is_object($value) && strpos($field_type, 'lob') !== false) {
$value = $value->load();
}
$result[strtolower($key)] = $value;
}
}
break;
case ZBX_DB_DB2:
if (!($result = db2_fetch_assoc($cursor))) {
db2_free_result($cursor);
} else {
// cast all of the values to string to be consistent with other DB drivers: all of them return
// only strings.
foreach ($result as &$value) {
if ($value !== null) {
$value = (string) $value;
}
}
unset($value);
}
break;
case ZBX_DB_SQLITE3:
if ($DB['TRANSACTIONS'] == 0) {
lock_sqlite3_access();
}
if (!($result = $cursor->fetchArray(SQLITE3_ASSOC))) {
unset($cursor);
} else {
// cast all of the values to string to be consistent with other DB drivers: all of them return
// only strings.
foreach ($result as &$value) {
$value = (string) $value;
}
unset($value);
}
if ($DB['TRANSACTIONS'] == 0) {
unlock_sqlite3_access();
}
break;
}
if ($result) {
if ($convertNulls) {
foreach ($result as $key => $val) {
if (is_null($val)) {
$result[$key] = '0';
}
}
}
return $result;
}
return false;
}
示例12: _close
function _close()
{
return @db2_free_result($this->_queryID);
}
示例13: otherdb
//.........这里部分代码省略.........
\t<option value="0" selected>command</option>
<option value="1">databases</option>
<option value="1">tables</option>
<option value="2">columns</option>
<option value="3">db config</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
//$db2string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$db2dbname;"."HOSTNAME=$db2host;PORT=$db2port;PROTOCOL=TCPIP;UID=$db2user;PWD=$db2pass;";
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
echo "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td bgcolor="#228B22"><b>' . db2_field_name($db2result);
echo "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td bgcolor="#B8B8E8">';
echo "{$db2row[$i]}";
echo '</td>';
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=w&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
\tStr = new Array(5);
Str[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
Str[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
Str[3] = "input 'D:\\createtable.sql';";
Str[4] = "shell netstat -an;";
\tfbform.fbsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
示例14: DBfetch
function DBfetch(&$cursor, $convertNulls = true)
{
global $DB;
$result = false;
if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) {
return $result;
}
switch ($DB['TYPE']) {
case ZBX_DB_MYSQL:
if (!($result = mysql_fetch_assoc($cursor))) {
mysql_free_result($cursor);
}
break;
case ZBX_DB_POSTGRESQL:
if (!($result = pg_fetch_assoc($cursor))) {
pg_free_result($cursor);
}
break;
case ZBX_DB_ORACLE:
if (ocifetchinto($cursor, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
$result = array();
foreach ($row as $key => $value) {
$field_type = zbx_strtolower(oci_field_type($cursor, $key));
$value = str_in_array($field_type, array('varchar', 'varchar2', 'blob', 'clob')) && is_null($value) ? '' : $value;
if (is_object($value) && zbx_stristr($field_type, 'lob') !== false) {
$value = $value->load();
}
$result[zbx_strtolower($key)] = $value;
}
}
break;
case ZBX_DB_DB2:
if (!($result = db2_fetch_assoc($cursor))) {
db2_free_result($cursor);
} else {
// cast all of the values to string to be consistent with other DB drivers: all of them return
// only strings.
foreach ($result as &$value) {
if ($value !== null) {
$value = (string) $value;
}
}
unset($value);
}
break;
case ZBX_DB_SQLITE3:
if ($DB['TRANSACTIONS'] == 0) {
lock_sqlite3_access();
}
if (!($result = $cursor->fetchArray(SQLITE3_ASSOC))) {
unset($cursor);
} else {
// cast all of the values to string to be consistent with other DB drivers: all of them return
// only strings.
foreach ($result as &$value) {
$value = (string) $value;
}
unset($value);
}
if ($DB['TRANSACTIONS'] == 0) {
unlock_sqlite3_access();
}
break;
}
if ($convertNulls && $result) {
foreach ($result as $key => $val) {
if (is_null($val)) {
$result[$key] = '0';
}
}
}
return $result;
}
示例15: disconnect
/**
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
*/
public function disconnect()
{
// TODO: Remove Error Suppression
@db2_free_result($this->results);
$this->connected = !@db2_close($this->connection);
return !$this->connected;
}