本文整理汇总了PHP中db2_stmt_errormsg函数的典型用法代码示例。如果您正苦于以下问题:PHP db2_stmt_errormsg函数的具体用法?PHP db2_stmt_errormsg怎么用?PHP db2_stmt_errormsg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db2_stmt_errormsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
function prepare($sql)
{
$stmt = @db2_prepare($this->_conn, $sql);
if (!$stmt) {
throw new DB2Exception(db2_stmt_errormsg());
}
return new DB2Statement($stmt);
}
示例2: __construct
/**
* This function initializes the class.
*
* @access public
* @override
* @param DB_Connection_Driver $connection the connection to be used
* @param string $sql the SQL statement to be queried
* @param integer $mode the execution mode to be used
* @throws Throwable_SQL_Exception indicates that the query failed
*
* @see http://www.php.net/manual/en/function.db2-prepare.php
* @see http://www.php.net/manual/en/function.db2-execute.php
* @see http://www.php.net/manual/en/function.db2-stmt-error.php
*/
public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL)
{
$resource = $connection->get_resource();
$command = @db2_prepare($resource, $sql);
if ($command === FALSE) {
throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_conn_errormsg($resource)));
}
if (!@db2_execute($command)) {
throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_stmt_errormsg($command)));
}
$this->command = $command;
$this->record = FALSE;
}
示例3: dbQuery
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
if ($show_errors) {
error_reporting(E_ALL);
} else {
error_reporting(E_PARSE);
}
// Connect to the IBM DB2 database management system
$link = db2_pconnect("testdb", "db2inst1", "testpass");
if (!$link) {
die(db2_conn_errormsg());
}
// Print results in HTML
print "<html><body>\n";
// Print SQL query to test sqlmap '--string' command line option
//print "<b>SQL query:</b> " . $query . "<br>\n";
// Perform SQL injection affected query
$stmt = db2_prepare($link, $query);
$result = db2_execute($stmt);
if (!$result) {
if ($show_errors) {
print "<b>SQL error:</b> " . db2_stmt_errormsg($stmt) . "<br>\n";
}
exit(1);
}
if (!$show_output) {
exit(1);
}
print "<b>SQL results:</b>\n";
print "<table border=\"1\">\n";
while ($line = db2_fetch_array($stmt)) {
print "<tr>";
foreach ($line as $col_value) {
print "<td>" . $col_value . "</td>";
}
print "</tr>\n";
if (!$all_results) {
break;
}
}
print "</table>\n";
print "</body></html>";
}
示例4: LCASE
<script src="js/jquery-1.11.3.min.js"></script>
</head>
<body>
<?php
//Connect to database
require_once "connect_db.php";
require_once "algorithm.php";
//Pull trait information from database
$songname = $_POST["name"];
$sql = "SELECT * FROM \"USER04893\" . \"Songs\" WHERE \"title\" = LCASE('" . $songname . "')";
$stmt = db2_exec($conn4, $sql);
$losongs;
$row;
//Fetches the list of similar songs
if (!$stmt) {
echo "SQL Statement Failed" . db2_stmt_errormsg() . "";
return;
} else {
$row = db2_fetch_array($stmt);
$top = getSongs($row);
$losongs = $top;
}
?>
<br>
<center><img src="images/logo.png" height="300px" width="300px" /></center>
<table>
<tr>
<td colspan="3">The song you searched for is: <?php
echo ucwords($row[0]);
?>
示例5: db2_stmt_errormsg
if (!$result2) {
echo "exec errormsg: " . db2_stmt_errormsg($stmt2);
die("Failed Query");
}
$bid = db2_fetch_array($stmt2);
if (!$bid) {
continue;
// NOT BIDDING ITEM
}
// I BID
// CHECK IF ENDED
$sql2 = "SELECT HIGHEST_BID_AMOUNT, END_DATE, END_TIME, HIGHEST_BIDDER FROM " . $computerName . ".BIDS WHERE ITEM_ID = {$itemID} and CURRENT DATE >= END_DATE";
$stmt2 = db2_prepare($conn, $sql2);
$result2 = db2_execute($stmt2);
if (!$result2) {
echo "exec errormsg: " . db2_stmt_errormsg($stmt2);
die("Failed Query");
}
$bid = db2_fetch_array($stmt2);
if (!$bid) {
continue;
}
$endTime = $bid[1] . ' ' . $bid[2];
$curTime = date("Y-m-d H:i:s");
if (strcmp($endTime, $curTime) > 0) {
continue;
}
$endTime = $bid[1] . ' ' . $bid[2];
$highestBid = $bid[0];
$highestBidder = $bid[3];
$condition = $row[3];
示例6: _execute
/**
* Executes a prepared statement.
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws Zend_Db_Statement_Db2_Exception
*/
public function _execute(array $params = null)
{
if (!$this->_stmt) {
return false;
}
$retval = true;
if ($params !== null) {
$retval = @db2_execute($this->_stmt, $params);
} else {
$retval = @db2_execute($this->_stmt);
}
if ($retval === false) {
/**
* @see Zend_Db_Statement_Db2_Exception
*/
require_once PHP_LIBRARY_PATH . 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception(db2_stmt_errormsg(), db2_stmt_error());
}
$this->_keys = array();
if ($field_num = $this->columnCount()) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
}
}
$this->_values = array();
if ($this->_keys) {
$this->_values = array_fill(0, count($this->_keys), null);
}
return $retval;
}
示例7: _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 = db2_prepare($this->_connectionID, $sql);
if ($stmtid == false) {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
return false;
}
}
if (!db2_execute($stmtid, $inputarr)) {
if ($this->_haserrorfunctions) {
$this->_errorMsg = db2_stmt_errormsg();
$this->_errorCode = db2_stmt_error();
}
return false;
}
} else {
if (is_array($sql)) {
$stmtid = $sql[1];
if (!db2_execute($stmtid)) {
if ($this->_haserrorfunctions) {
$this->_errorMsg = db2_stmt_errormsg();
$this->_errorCode = db2_stmt_error();
}
return false;
}
} else {
$stmtid = @db2_exec($this->_connectionID, $sql);
}
}
$this->_lastAffectedRows = 0;
if ($stmtid) {
if (@db2_num_fields($stmtid) == 0) {
$this->_lastAffectedRows = db2_num_rows($stmtid);
$stmtid = true;
} else {
$this->_lastAffectedRows = 0;
}
if ($this->_haserrorfunctions) {
$this->_errorMsg = '';
$this->_errorCode = 0;
} else {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
} else {
if ($this->_haserrorfunctions) {
$this->_errorMsg = db2_stmt_errormsg();
$this->_errorCode = db2_stmt_error();
} else {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
}
return $stmtid;
}
示例8: _rawQuery
protected function _rawQuery($sql)
{
$conn = $this->_db->getConnection();
$result = @db2_exec($conn, $sql);
if (!$result) {
$e = db2_stmt_errormsg();
throw new Db\Exception("SQL error for \"{$sql}\": {$e}");
}
}
示例9: otherdb
//.........这里部分代码省略.........
$db2query = stripslashes($db2query);
print <<<END
<form method="POST" name="db2form" action="?s=gg&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br>
<script language="javascript">
function db2Full(i){
Str = new Array(4);
\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/>
示例10: _execute
/**
* Executes a prepared statement.
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws \Zend\Db\Statement\Db2Exception
*/
public function _execute(array $params = null)
{
if (!$this->_stmt) {
return false;
}
$retval = true;
if ($params !== null) {
$retval = @db2_execute($this->_stmt, $params);
} else {
$retval = @db2_execute($this->_stmt);
}
if ($retval === false) {
throw new Db2Exception(db2_stmt_errormsg(), db2_stmt_error());
}
$this->_keys = array();
if ($field_num = $this->columnCount()) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
}
}
$this->_values = array();
if ($this->_keys) {
$this->_values = array_fill(0, count($this->_keys), null);
}
return $retval;
}
示例11: error
/**
* This function returns the last error string.
*
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-04-16
*/
function error()
{
return db2_stmt_errormsg($this->conn);
}
示例12: errorMessage
public static function errorMessage($conn)
{
return db2_stmt_errormsg();
}
示例13: error
/**
* error()
*
* This function returns the last error string.
*
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-04-16
*/
function error()
{
return db2_stmt_errormsg();
}
示例14: otherdb
//.........这里部分代码省略.........
print <<<END
<form method="POST" name="db2form" action="?s=w&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br><br>
<script language="javascript">
function db2Full(i){
\tStr = new Array(4);
Str[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
Str[2] = "select name from sysibm.systables;";
Str[3] = "select colname from syscat.columns where tabname='table_name';";
Str[4] = "db2 get db cfg for db_name;";
\tdb2form.db2sql.value = Str[i];
\treturn 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>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);
示例15: check_and_print_stmt_error
private function check_and_print_stmt_error($stmt = false)
{
$skip_errnos = array('02000');
if ($stmt) {
if ($error = db2_stmt_errormsg($stmt)) {
$errno = db2_stmt_error($stmt);
if (in_array($errno, $skip_errnos)) {
return false;
}
$this->print_error($error, $errno);
return true;
}
return false;
} else {
if ($error = db2_stmt_errormsg()) {
$errno = db2_stmt_error();
if (in_array($errno, $skip_errnos)) {
return false;
}
$this->print_error($error, $errno);
return true;
}
}
return false;
}