summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib/dblib_driver.c
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2013-10-05 18:26:25 -0700
committerStanley Sufficool <ssufficool@php.net>2013-10-05 18:26:25 -0700
commit9c7dbb0487f5991fde03873ea8f5e66d6688415f (patch)
tree29b9f63e12f98239070b8c57fff1c53ff1acb804 /ext/pdo_dblib/dblib_driver.c
parent3e023c3ddf9e80046803a989f4951ee16d3b8f9b (diff)
downloadphp-git-9c7dbb0487f5991fde03873ea8f5e66d6688415f.tar.gz
Fix bug #64338 pdo_dblib can't connect to Azure SQL
Diffstat (limited to 'ext/pdo_dblib/dblib_driver.c')
-rw-r--r--ext/pdo_dblib/dblib_driver.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 8e4cbb7a48..daf5494d58 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -350,9 +350,10 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
DBSETLAPP(H->login, vars[1].optval);
+/* DBSETLDBNAME is only available in FreeTDS 0.92 or above */
#ifdef DBSETLDBNAME
if (vars[3].optval) {
- DBSETLDBNAME(H->login, vars[3].optval);
+ if(FAIL == DBSETLDBNAME(H->login, vars[3].optval)) goto cleanup;
}
#endif
@@ -362,6 +363,16 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
goto cleanup;
}
+/*
+ * FreeTDS < 0.92 does not support the DBSETLDBNAME option
+ * Send use database here after login (Will not work with SQL Azure)
+ */
+#ifndef DBSETLDBNAME
+ if (vars[3].optval) {
+ if(FAIL == dbuse(H->link, vars[3].optval)) goto cleanup;
+ }
+#endif
+
#if PHP_DBLIB_IS_MSSQL
/* dblib do not return more than this length from text/image */
DBSETOPT(H->link, DBTEXTLIMIT, "2147483647");
@@ -371,29 +382,12 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
DBSETOPT(H->link, DBTEXTSIZE, "2147483647");
/* allow double quoted indentifiers */
- DBSETOPT(H->link, DBQUOTEDIDENT, NULL);
+ DBSETOPT(H->link, DBQUOTEDIDENT, "1");
ret = 1;
dbh->max_escaped_char_length = 2;
dbh->alloc_own_columns = 1;
-#if 0
- /* Cache the supported data types from the servers systypes table */
- if(dbcmd(H->link, "select usertype, name from systypes order by usertype") != FAIL) {
- if(dbsqlexec(H->link) != FAIL) {
- dbresults(H->link);
- while (dbnextrow(H->link) == SUCCESS) {
- val = dbdata(H->link, 1);
- add_index_string(pdo_dblib_datatypes, *val, dbdata(H->link, 2), 1);
- }
- }
- /* Throw out any remaining resultsets */
- dbcancel(H-link);
- }
-#endif
-
-
-
cleanup:
for (i = 0; i < nvars; i++) {
if (vars[i].freeme) {