本文整理汇总了PHP中odbc_error函数的典型用法代码示例。如果您正苦于以下问题:PHP odbc_error函数的具体用法?PHP odbc_error怎么用?PHP odbc_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了odbc_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeUserPassword
public function changeUserPassword($userName, $userOldPassword, $userNewPassword, $portalID)
{
VDSN;
$conn = odbc_connect(VDSN, USER, PW) or die('ODBC Error:: ' . odbc_error() . ' :: ' . odbc_errormsg() . ' :: ' . VDSN);
//test for user name
if ($conn) {
$sql = "SELECT '1' outputFlag FROM Portal_User WHERE User_Name = '" . $userName . "' AND Portal_ID = '" . $portalID . "'";
$rs = odbc_exec($conn, $sql);
$row = odbc_fetch_row($rs);
if ($row == null) {
odbc_close($conn);
return "You have entered an invalid user name; please try again.";
}
}
//test for password
if ($conn) {
$sql = "SELECT '1' FROM Users WHERE User_Name = '" . $userName . "' AND User_Password = '" . $userOldPassword . "'";
$rs = odbc_exec($conn, $sql);
$row = odbc_fetch_row($rs);
if ($row == null) {
odbc_close($conn);
return "You have entered an invalid password for your account; please try again.";
}
}
//save new password
if ($conn) {
$sql = "UPDATE Users SET User_Password = '" . $userNewPassword . "' WHERE User_Name = '" . $userName . "'";
$rs = odbc_exec($conn, $sql);
}
return "OK";
}
示例2: getId
/**
* @see IdGenerator::getId()
*/
public function getId($seqname = null)
{
if ($seqname === null) {
throw new SQLException('You must specify the sequence name when calling getId() method.');
}
$triedcreate = false;
while (1) {
try {
$n = $this->conn->executeUpdate("UPDATE {$seqname} SET id = id + 1", ResultSet::FETCHMODE_NUM);
if ($n == 0) {
throw new SQLException('Failed to update IdGenerator id', $this->conn->nativeError());
}
$rs = $this->conn->executeQuery("SELECT id FROM {$seqname}", ResultSet::FETCHMODE_NUM);
} catch (SQLException $e) {
$odbcerr = odbc_error($this->conn->getResource());
if ($triedcreate || $odbcerr != 'S0000' && $odbcerr != 'S0002') {
throw $e;
}
$this->drop($seqname, true);
$this->create($seqname);
$triedcreate = true;
continue;
}
break;
}
$rs->first();
return $rs->getInt(1);
}
示例3: doquery
function doquery($query, $table, $fetch = false)
{
global $link, $debug, $ugamela_root_path;
@(include $ugamela_root_path . 'config.php');
if (!$link) {
$link = odbc_connect($dbsettings["server"], $dbsettings["user"], $dbsettings["pass"]) or $debug->error(odbc_error() . "<br />{$query}", "SQL Error");
//message(mysql_error()."<br />$query","SQL Error");
odbc_select_db($dbsettings["name"]) or $debug->error(odbc_error() . "<br />{$query}", "SQL Error");
}
// por el momento $query se mostrara
// pero luego solo se vera en modo debug
$sqlquery = odbc_exec($query, str_replace("{{table}}", $dbsettings["prefix"] . $table)) or $debug->error(odbc_error() . "<br />{$query}", "SQL Error");
//message(mysql_error()."<br />$query","SQL Error");
unset($dbsettings);
//se borra la array para liberar algo de memoria
global $numqueries, $debug;
//,$depurerwrote003;
$numqueries++;
//$depurerwrote003 .= ;
$debug->add("<tr><th>Query {$numqueries}: </th><th>{$query}</th><th>{$table}</th><th>{$fetch}</th></tr>");
if ($fetch) {
//hace el fetch y regresa $sqlrow
$sqlrow = odbc_fetch_array($sqlquery);
return $sqlrow;
} else {
//devuelve el $sqlquery ("sin fetch")
return $sqlquery;
}
}
示例4: sql_result
function sql_result($query, $conn = NULL)
{
if (DATABASE == "mysql") {
if (is_null($conn)) {
$qryRslt = @mysql_query($query, $GLOBALS["db_con"]);
} else {
$qryRslt = @mysql_query($query, $conn);
}
if (!$qryRslt) {
echo $query;
error_log(date("F j, Y, g:i a") . "\t{$query}\n" . $_SERVER["PATH_INFO"] . "\n\t" . @mysql_error() . "\n\n", 3, "sql_error.log");
die("<br><font color=\"red\">Due to some technical problem, your Transaction was <b>NOT</b> successful</font>\n");
}
return $qryRslt;
} else {
if (DATABASE == "odbc") {
if (is_null($conn)) {
$qryRslt = @odbc_exec($GLOBALS["db_con"], $query);
} else {
$qryRslt = @odbc_exec($conn, $query);
}
if (!$qryRslt) {
error_log(date("F j, Y, g:i a") . "\t{$query}\n" . $_SERVER["PATH_INFO"] . "\n\t" . @odbc_error() . "\n\n", 3, "sql_error.log");
die("<br><font color=\"red\">Due to some technical problem, your Transaction was <b>NOT</b> successful</font>\n");
}
return $qryRslt;
}
}
}
示例5: chkConnect
/**
* check the connection.
*
* @return void
*/
public static function chkConnect($config)
{
$conid = @odbc_connect($config['dsn'], $config['username'], $config['password'], SQL_CUR_USE_ODBC);
if (odbc_error()) {
//return odbc_errormsg(); //SQL Server 2005 不支持 utf-8 编码,其使用 UCS-2 编码架构(所有 unicode 字符都占用 2 个字节)。
return 'connect failed';
}
return true;
}
示例6: setError
/**
* set error code and message based on last odbc connection/prepare/execute error.
*
* @todo: consider using GET DIAGNOSTICS for even more message text:
* http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Frzala%2Frzalafinder.htm
*
* @param null $conn
*/
protected function setError($conn = null)
{
// is conn resource provided, or do we get last error?
if ($conn) {
$this->setErrorCode(odbc_error($conn));
$this->setErrorMsg(odbc_errormsg($conn));
} else {
$this->setErrorCode(odbc_error());
$this->setErrorMsg(odbc_errormsg());
}
}
示例7: die_sql
private function die_sql($sql, $line, $file, $function, $class)
{
error_log($file . ' : L ' . $line . chr(10) . $sql . chr(10) . odbc_errormsg($this->link));
$err = '<span style="font-size:18px;font-weight:bold;">lisha</span><br /><br />';
$err .= 'Erreur MySQL<br /><br />';
$err .= '<b style="color:#DD2233;">Erreur ' . odbc_error($this->link) . "</b> : <b>" . odbc_errormsg($this->link) . '</b><br /><br />';
$err .= 'Classe : ' . $class . ' - Ligne : ' . $line . ' - ' . $file . ' - ' . $function . '<br /><br /><br />';
$err .= '<textarea style="width:90%;height:200px;;">' . $sql . '</textarea>';
echo $err;
die;
}
示例8: raiseError
public function raiseError($sql = NULL, $prms = array())
{
$error_id = odbc_error($this->_con);
if (strlen($error_id) == 5) {
$error_msg = "[" . $error_id . "] " . odbc_errormsg($this->_con);
//odbc_close($this->_con);
if (!empty($sql)) {
$error_msg = $error_msg . "-------------------------\nSQL trace: " . $sql . ", \n-------------------------\nParams: " . print_r($prms, 1);
}
throw new Error($error_msg);
}
}
示例9: 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);
}
示例10: executeQuery
public function executeQuery($sql)
{
//echo $sql;
$res = odbc_exec(self::connection(), $sql);
//execute sql query using db connection
if (!$res) {
throw new Exception(odbc_error());
}
self::closeConnection();
// close db connection
return $res;
//return result resource
}
示例11: Query
function Query($query)
{
if ($this->conn)
{
$result = odbc_exec($this->conn, $query);
if (odbc_error()) $this->setError(odbc_error());
return $result;
}
else
{
return false;
}
}
示例12: 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;
}
示例13: ErrorNo
function ErrorNo()
{
if ($this->haserrorfunctions) {
$e = odbc_error($this->_connectionID);
// bug in 4.0.6, error number can be corrupted string (should be 6 digits)
// so we check and patch
if (strlen($e) <= 2) {
return 0;
}
return $e;
} else {
return ADODBConnection::ErrorNo();
}
}
示例14: login
private function login(client_login_info $login_info)
{
//TODO: odbc connect probably supports these DSNs: http://www.connectionstrings.com/oracle/
//may be something like "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;"
$connect = odbc_connect($login_info->DSN, $login_info->user, $login_info->pass);
if ($connect === false) {
$this->login_error_message = odbc_error() . ": " . odbc_errormsg();
} else {
$this->logged_in = true;
$this->connection = $connect;
}
if ($this->logged_in) {
$login_info->save_in_cookies();
}
}
示例15: open_odbc_connection
function open_odbc_connection()
{
global $debug, $ze_hostname, $ze_login, $ze_pwd, $conn_o;
$cnx_err = false;
// erreur de connexion
if ($debug) {
echo "Ouverture de la connexion ODBC<br />";
}
$conn_o = odbc_connect($ze_hostname, $ze_login, $ze_pwd);
if (!$conn_o) {
$cnx_err = true;
$msg = "Echec de la connexion au serveur : " . odbc_error();
if ($debug) {
echo $msg . "<br>";
}
}
return $cnx_err;
}