summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Boeren <mboeren@php.net>2001-06-13 13:35:17 +0000
committerMarc Boeren <mboeren@php.net>2001-06-13 13:35:17 +0000
commitbfd1f986b173d62a3e3a455b71073f7a97ee9c51 (patch)
tree4e5e4719bae0994340499c46789828fa07273375
parentf3fa23ace99c3c32ea670ddf2960e5dbf6f370c7 (diff)
downloadphp-git-bfd1f986b173d62a3e3a455b71073f7a97ee9c51.tar.gz
Latest (minor) fixes: mssql, mysql and odbc now pass the testset correctly.
# I need a working setup to test pgsql with the test-set as well.
-rw-r--r--ext/dbx/dbx_mssql.c2
-rw-r--r--ext/dbx/dbx_odbc.c13
-rw-r--r--ext/dbx/tests/003.phpt5
-rw-r--r--ext/dbx/tests/006.phpt19
-rw-r--r--ext/dbx/tests/dbx_test.p41
5 files changed, 68 insertions, 12 deletions
diff --git a/ext/dbx/dbx_mssql.c b/ext/dbx/dbx_mssql.c
index 5568ee2b53..2d754086e6 100644
--- a/ext/dbx/dbx_mssql.c
+++ b/ext/dbx/dbx_mssql.c
@@ -51,6 +51,7 @@ int dbx_mssql_connect(zval ** rv, zval ** host, zval ** db, zval ** username, zv
/* also close connection */
number_of_arguments=1;
arguments[0]=&returned_zval;
+ zend_list_addref(returned_zval->value.lval);
dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &select_db_zval, number_of_arguments, arguments);
if (select_db_zval) zval_ptr_dtor(&select_db_zval);
zval_ptr_dtor(&returned_zval);
@@ -88,6 +89,7 @@ int dbx_mssql_pconnect(zval ** rv, zval ** host, zval ** db, zval ** username, z
/* also close connection */
number_of_arguments=1;
arguments[0]=&returned_zval;
+ zend_list_addref(returned_zval->value.lval);
dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &select_db_zval, number_of_arguments, arguments);
if (select_db_zval) zval_ptr_dtor(&select_db_zval);
zval_ptr_dtor(&returned_zval);
diff --git a/ext/dbx/dbx_odbc.c b/ext/dbx/dbx_odbc.c
index ca5ad9ff5c..13da2da653 100644
--- a/ext/dbx/dbx_odbc.c
+++ b/ext/dbx/dbx_odbc.c
@@ -67,13 +67,24 @@ int dbx_odbc_close(zval ** rv, zval ** dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
int number_of_arguments=1;
zval ** arguments[1];
zval * returned_zval=NULL;
+ int exit_status=EG(exit_status);
+
+ int actual_resource_type;
+ void *resource;
+ resource = zend_list_find((*dbx_handle)->value.lval, &actual_resource_type);
+ if (!resource) {
+ return 0;
+ }
arguments[0]=dbx_handle;
dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_close", &returned_zval, number_of_arguments, arguments);
- if (!returned_zval || returned_zval->type!=IS_BOOL) {
+
+ if (!returned_zval || returned_zval->type!=IS_NULL) {
if (returned_zval) zval_ptr_dtor(&returned_zval);
return 0;
}
+ convert_to_long_ex(&returned_zval);
+ returned_zval->value.lval=1;
MOVE_RETURNED_TO_RV(rv, returned_zval);
return 1;
}
diff --git a/ext/dbx/tests/003.phpt b/ext/dbx/tests/003.phpt
index 2c5a8ec762..03eec20ddf 100644
--- a/ext/dbx/tests/003.phpt
+++ b/ext/dbx/tests/003.phpt
@@ -7,7 +7,6 @@ dbx_connect
--FILE--
<?php
include_once("ext/dbx/tests/dbx_test.p");
-$module_name="mysql";
$nonexisting_database="nonexisting_database";
$nonexisting_username="nonexisting_username";
$nonexisting_password="nonexisting_password";
@@ -87,9 +86,9 @@ if ($dlo1!=0 && $dlo2!=0) {
dbx_close($dlo2);
}
$dlo1 = dbx_connect($module, $host, $database, $username, $password);
-$dlo2 = dbx_connect($module, $host, $nonexisting_database, $username, $password);
+$dlo2 = @dbx_connect($module, $host, $nonexisting_database, $username, $password);
if ($dlo1!=0 && $dlo2==0) {
- print('multiple connects (2nd fails on database-name) ok'."\n");
+ print('multiple connects (2nd fails on database-name) ok'."\n");
dbx_close($dlo1);
}
?>
diff --git a/ext/dbx/tests/006.phpt b/ext/dbx/tests/006.phpt
index cf4d118511..cfe1e48b97 100644
--- a/ext/dbx/tests/006.phpt
+++ b/ext/dbx/tests/006.phpt
@@ -7,6 +7,16 @@ dbx_error
--FILE--
<?php
include_once("ext/dbx/tests/dbx_test.p");
+if ($module==DBX_ODBC) {
+ // ODBC module doesn't have an error-message-function (yet?)
+ print('query generated an error: dbx_error works ok'."\n");
+ print('query is valid: dbx_error works ok'."\n");
+ print('wrong dbx_link_object: dbx_error failure works ok'."\n");
+ print('too many parameters: dbx_error failure works ok'."\n");
+ print('too few parameters: dbx_error failure works ok'."\n");
+ }
+else {
+
$sql_statement = "select * from tbl";
$invalid_sql_statement = "invalid select * from tbl";
$dlo = dbx_connect($module, $host, $database, $username, $password);
@@ -14,12 +24,13 @@ if (!$dlo) {
print('this won\'t work'."\n");
}
else {
- dbx_query($dlo, "select nonexistingfield from tbl");
- if (strlen(dbx_error($dlo))) {
+ @dbx_query($dlo, "select nonexistingfield from tbl");
+ if (($module==DBX_MSSQL && dbx_error($dlo)!="Changed database context to '".$database."'.")
+ || strlen(dbx_error($dlo))) {
print('query generated an error: dbx_error works ok'."\n");
}
dbx_query($dlo, "select description from tbl");
- if (!strlen(dbx_error($dlo))) {
+ if (!strlen(dbx_error($dlo)) || ($module==DBX_MSSQL && dbx_error($dlo)=="Changed database context to '".$database."'.")) {
print('query is valid: dbx_error works ok'."\n");
}
if (!@dbx_error(0)) {
@@ -33,6 +44,8 @@ else {
}
dbx_close($dlo);
}
+
+ }
?>
--EXPECT--
query generated an error: dbx_error works ok
diff --git a/ext/dbx/tests/dbx_test.p b/ext/dbx/tests/dbx_test.p
index f639b93f78..d2193be246 100644
--- a/ext/dbx/tests/dbx_test.p
+++ b/ext/dbx/tests/dbx_test.p
@@ -1,7 +1,38 @@
<?php
-$module=DBX_MYSQL;
-$host="";
-$database="dbx_test";
-$username="dbx_testuser";
-$password="dbx_testpassword";
+$connection = DBX_MYSQL;
+switch ($connection) {
+ case DBX_MYSQL:
+ $module=DBX_MYSQL;
+ $host="";
+ $database="dbx_test";
+ $username="dbx_testuser";
+ $password="dbx_testpassword";
+ $module_name="mysql";
+ break;
+ case DBX_MSSQL:
+ $module=DBX_MSSQL;
+ $host="HOLLY";
+ $database="dbx_test";
+ $username="";
+ $password="";
+ $module_name="mssql";
+ break;
+ case DBX_ODBC:
+ $module=DBX_ODBC;
+ $host="localhost";
+ $database="dbx_test_mysql"; // "dbx_test_access";
+ $username="dbx_testuser";
+ $password="dbx_testpassword";
+ $module_name="odbc";
+ break;
+ case DBX_PGSQL:
+ $module=DBX_PGSQL;
+ $host="";
+ $database="dbx_test";
+ $username="";
+ $password="";
+ $module_name="pgsql";
+ break;
+ }
+
?> \ No newline at end of file