summaryrefslogtreecommitdiff
path: root/ext/pdo_odbc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_odbc')
-rwxr-xr-xext/pdo_odbc/odbc_driver.c45
-rwxr-xr-xext/pdo_odbc/package.xml51
-rw-r--r--ext/pdo_odbc/package2.xml69
-rwxr-xr-xext/pdo_odbc/pdo_odbc.c4
4 files changed, 106 insertions, 63 deletions
diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c
index b85dde44c..6ef1b7ff4 100755
--- a/ext/pdo_odbc/odbc_driver.c
+++ b/ext/pdo_odbc/odbc_driver.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: odbc_driver.c,v 1.27.2.1 2005/09/26 21:37:33 wez Exp $ */
+/* $Id: odbc_driver.c,v 1.27.2.2 2005/12/14 04:56:22 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -58,8 +58,10 @@ static int pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *inf
void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement, char *what, const char *file, int line TSRMLS_DC) /* {{{ */
{
- RETCODE rc;
- SWORD errmsgsize = 0;
+ SQLRETURN rc;
+ SQLSMALLINT errmsgsize = 0;
+ SQLHANDLE eh;
+ SQLSMALLINT htype, recno = 1;
pdo_odbc_db_handle *H = (pdo_odbc_db_handle*)dbh->driver_data;
pdo_odbc_errinfo *einfo = &H->einfo;
pdo_odbc_stmt *S = NULL;
@@ -75,8 +77,19 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
if (statement == SQL_NULL_HSTMT && S) {
statement = S->stmt;
}
-
- rc = SQLError(H->env, H->dbc, statement, einfo->last_state, &einfo->last_error,
+
+ if (statement) {
+ htype = SQL_HANDLE_STMT;
+ eh = statement;
+ } else if (H->dbc) {
+ htype = SQL_HANDLE_DBC;
+ eh = H->dbc;
+ } else {
+ htype = SQL_HANDLE_ENV;
+ eh = H->env;
+ }
+
+ rc = SQLGetDiagRec(htype, eh, recno++, einfo->last_state, &einfo->last_error,
einfo->last_err_msg, sizeof(einfo->last_err_msg)-1, &errmsgsize);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -94,6 +107,20 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
*pdo_err, what, einfo->last_error, einfo->last_err_msg);
}
+
+ /* just like a cursor, once you start pulling, you need to keep
+ * going until the end; SQL Server (at least) will mess with the
+ * actual cursor state if you don't finish retrieving all the
+ * diagnostic records (which can be generated by PRINT statements
+ * in the query, for instance). */
+ while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
+ char discard_state[5];
+ char discard_buf[1024];
+ SQLINTEGER code;
+ rc = SQLGetDiagRec(htype, eh, recno++, discard_state, &code,
+ discard_buf, sizeof(discard_buf)-1, &errmsgsize);
+ }
+
}
/* }}} */
@@ -175,14 +202,12 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p
pdo_odbc_stmt_error("SQLPrepare");
}
+ stmt->driver_data = S;
+ stmt->methods = &odbc_stmt_methods;
+
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- SQLFreeHandle(SQL_HANDLE_STMT, S->stmt);
return 0;
}
-
- stmt->driver_data = S;
- stmt->methods = &odbc_stmt_methods;
-
return 1;
}
diff --git a/ext/pdo_odbc/package.xml b/ext/pdo_odbc/package.xml
deleted file mode 100755
index 3d066fbaa..000000000
--- a/ext/pdo_odbc/package.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package version="1.0">
- <name>PDO_ODBC</name>
- <summary>ODBC v3 Interface driver for PDO</summary>
- <maintainers>
- <maintainer>
- <user>wez</user>
- <name>Wez Furlong</name>
- <email>wez@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <configureoptions>
- <configureoption name="with-pdo-odbc" prompt="flavour,dir? (just leave blank for help)"/>
-</configureoptions>
- <description>
- This extension provides an ODBC v3 driver for PDO. It supports unixODBC
- and IBM DB2 libraries, and will support more in future releases.
- </description>
- <license>PHP</license>
- <release>
- <state>stable</state>
- <version>1.0</version>
- <date>2005-11-26</date>
-
- <notes>
-You need to install the PDO core module before you can make use of this one.
-You also require either IBM DB2 CLI libraries or unixODBC.
-
-If you are running on windows, you can download the binary from here:
-http://pecl4win.php.net/ext.php/php_pdo_odbc.dll
- </notes>
-
- <filelist>
- <file role="src" name="config.m4"/>
- <file role="src" name="config.w32"/>
- <file role="src" name="pdo_odbc.c"/>
- <file role="src" name="odbc_driver.c"/>
- <file role="src" name="odbc_stmt.c"/>
- <file role="src" name="php_pdo_odbc.h"/>
- <file role="src" name="php_pdo_odbc_int.h"/>
-
- <file role="doc" name="CREDITS"/>
- </filelist>
- <deps>
- <dep type="php" rel="ge" version="5.0.3"/>
- <dep type="ext" rel="ge" name="pdo" version="1.0"/>
- </deps>
- </release>
-</package>
diff --git a/ext/pdo_odbc/package2.xml b/ext/pdo_odbc/package2.xml
new file mode 100644
index 000000000..ce50b8d42
--- /dev/null
+++ b/ext/pdo_odbc/package2.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.4.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+http://pear.php.net/dtd/tasks-1.0.xsd
+http://pear.php.net/dtd/package-2.0
+http://pear.php.net/dtd/package-2.0.xsd">
+ <name>PDO_ODBC</name>
+ <channel>pecl.php.net</channel>
+ <summary>ODBC v3 Interface driver for PDO</summary>
+ <description>This extension provides an ODBC v3 driver for PDO. It supports unixODBC
+and IBM DB2 libraries, and will support more in future releases.
+ </description>
+ <lead>
+ <name>Wez Furlong</name>
+ <user>wez</user>
+ <email>wez@php.net</email>
+ <active>yes</active>
+ </lead>
+ <date>2005-12-04</date>
+ <version>
+ <release>1.0.1</release>
+ <api>1.0.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+- repackage with package2.xml
+
+You require either IBM DB2 CLI libraries or unixODBC to use this package.
+
+If you are running on windows, you can download the binary from here:
+http://pecl4win.php.net/ext.php/php_pdo_odbc.dll
+
+ </notes>
+ <contents>
+ <dir name="/">
+ <file name="config.m4" role="src" />
+ <file name="config.w32" role="src" />
+ <file name="CREDITS" role="doc" />
+ <file name="odbc_driver.c" role="src" />
+ <file name="odbc_stmt.c" role="src" />
+ <file name="pdo_odbc.c" role="src" />
+ <file name="php_pdo_odbc.h" role="src" />
+ <file name="php_pdo_odbc_int.h" role="src" />
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0.3</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0</min>
+ </pearinstaller>
+ <package>
+ <name>pdo</name>
+ <channel>pecl.php.net</channel>
+ <min>1.0</min>
+ <providesextension>PDO</providesextension>
+ </package>
+ </required>
+ </dependencies>
+ <providesextension>PDO_ODBC</providesextension>
+ <extsrcrelease>
+ <configureoption name="with-pdo-odbc" prompt="flavour,dir? (just leave blank for help)" />
+ </extsrcrelease>
+</package>
diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c
index eaec0ba85..43292d8fd 100755
--- a/ext/pdo_odbc/pdo_odbc.c
+++ b/ext/pdo_odbc/pdo_odbc.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_odbc.c,v 1.14.2.6 2005/11/26 20:50:07 wez Exp $ */
+/* $Id: pdo_odbc.c,v 1.14.2.7 2005/12/04 22:34:26 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -60,7 +60,7 @@ zend_module_entry pdo_odbc_module_entry = {
NULL,
NULL,
PHP_MINFO(pdo_odbc),
- "1.0",
+ "1.0.1",
STANDARD_MODULE_PROPERTIES
};
/* }}} */