summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThies C. Arntzen <thies@php.net>1999-10-12 14:53:15 +0000
committerThies C. Arntzen <thies@php.net>1999-10-12 14:53:15 +0000
commit86bb3fa0c0ca46f4c2c2c69d0e66b3f9de1b1e99 (patch)
tree5b4b53de949e493a35626e77d69ff1fb8d226130
parent6d7c18c1f511b3d2e8ba5dc50d919ea352bef3ad (diff)
downloadphp-git-86bb3fa0c0ca46f4c2c2c69d0e66b3f9de1b1e99.tar.gz
new improved resource-API (i hope everything still compiles)
-rw-r--r--ext/msql/php_msql.c27
-rw-r--r--ext/mysql/php_mysql.c39
-rw-r--r--ext/oci8/oci8.c8
-rw-r--r--ext/odbc/php_odbc.c52
-rw-r--r--ext/oracle/oracle.c67
-rw-r--r--ext/sybase_ct/php_sybase_ct.c15
6 files changed, 76 insertions, 132 deletions
diff --git a/ext/msql/php_msql.c b/ext/msql/php_msql.c
index 7c9cf42b71..40014bcd23 100644
--- a/ext/msql/php_msql.c
+++ b/ext/msql/php_msql.c
@@ -402,8 +402,7 @@ DLEXPORT PHP_FUNCTION(msql_close)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
zend_list_delete(id);
RETURN_TRUE;
@@ -438,8 +437,7 @@ DLEXPORT PHP_FUNCTION(msql_select_db)
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(db);
@@ -478,8 +476,7 @@ DLEXPORT PHP_FUNCTION(msql_create_db)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(db);
if (msqlCreateDB(msql,db->value.str.val)<0) {
@@ -517,8 +514,7 @@ DLEXPORT PHP_FUNCTION(msql_drop_db)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(db);
if (msqlDropDB(msql,db->value.str.val)<0) {
@@ -557,8 +553,7 @@ DLEXPORT PHP_FUNCTION(msql_query)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(query);
if ((af_rows = msqlQuery(msql,query->value.str.val))==-1) {
@@ -596,8 +591,7 @@ DLEXPORT PHP_FUNCTION(msql_db_query)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(db);
if (msqlSelectDB(msql,db->value.str.val)==-1) {
@@ -637,8 +631,7 @@ DLEXPORT PHP_FUNCTION(msql_list_dbs)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
if ((msql_result=msqlListDBs(msql))==NULL) {
php_error(E_WARNING,"Unable to save mSQL query result");
@@ -676,8 +669,7 @@ DLEXPORT PHP_FUNCTION(msql_list_tables)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(db);
if (msqlSelectDB(msql,db->value.str.val)==-1) {
@@ -719,8 +711,7 @@ DLEXPORT PHP_FUNCTION(msql_list_fields)
break;
}
- msql = (int) zend_fetch_resource_ex(&msql_link, id, "mSQL link", 2, msql_globals.le_link, msql_globals.le_plink);
- ZEND_VERIFY_RESOURCE(msql);
+ ZEND_FETCH_RESOURCE2(msql, int, &msql_link, id, "mSQL-Link", msql_globals.le_link, msql_globals.le_plink);
convert_to_string(db);
if (msqlSelectDB(msql,db->value.str.val)==-1) {
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 7302599067..42229e67e9 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -642,8 +642,7 @@ PHP_FUNCTION(mysql_close)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
zend_list_delete(id);
RETURN_TRUE;
@@ -680,8 +679,7 @@ PHP_FUNCTION(mysql_select_db)
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(db);
@@ -722,8 +720,7 @@ PHP_FUNCTION(mysql_create_db)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(db);
if (mysql_create_db(mysql, (*db)->value.str.val)==0) {
@@ -764,8 +761,7 @@ PHP_FUNCTION(mysql_drop_db)
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(db);
if (mysql_drop_db(mysql, (*db)->value.str.val)==0) {
@@ -806,8 +802,7 @@ PHP_FUNCTION(mysql_query)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(query);
/* mysql_query binary unsafe, use mysql_real_query */
@@ -862,8 +857,7 @@ PHP_FUNCTION(mysql_db_query)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(db);
if (mysql_select_db(mysql, (*db)->value.str.val)!=0) {
@@ -920,8 +914,7 @@ PHP_FUNCTION(mysql_list_dbs)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
if ((mysql_result=mysql_list_dbs(mysql, NULL))==NULL) {
php_error(E_WARNING,"Unable to save MySQL query result");
@@ -961,8 +954,7 @@ PHP_FUNCTION(mysql_list_tables)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(db);
if (mysql_select_db(mysql, (*db)->value.str.val)!=0) {
@@ -1006,8 +998,7 @@ PHP_FUNCTION(mysql_list_fields)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
convert_to_string_ex(db);
if (mysql_select_db(mysql, (*db)->value.str.val)!=0) {
@@ -1050,8 +1041,7 @@ PHP_FUNCTION(mysql_error)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
RETURN_STRING(mysql_error(mysql),1);
}
@@ -1086,8 +1076,7 @@ PHP_FUNCTION(mysql_errno)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
RETURN_LONG(mysql_errno(mysql));
}
@@ -1120,8 +1109,7 @@ PHP_FUNCTION(mysql_affected_rows)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
/* conversion from int64 to long happing here */
return_value->value.lval = (long) mysql_affected_rows(mysql);
@@ -1155,8 +1143,7 @@ PHP_FUNCTION(mysql_insert_id)
break;
}
- mysql = (MYSQL *) zend_fetch_resource_ex(mysql_link, id, "MySQL link", 2, le_link, le_plink);
- ZEND_VERIFY_RESOURCE(mysql);
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
/* conversion from int64 to long happing here */
return_value->value.lval = (long) mysql_insert_id(mysql);
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 8160cd6d10..f68f45b642 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -727,7 +727,7 @@ static oci_connection *oci_get_conn(zval **conn)
{
oci_connection *connection;
- connection = (oci_connection *) zend_fetch_resource_ex(conn, -1, "OCI8-Connection", 1, le_conn);
+ connection = (oci_connection *) zend_fetch_resource(conn, -1, "OCI8-Connection", NULL, 1, le_conn);
if (connection && connection->open) {
return connection;
@@ -743,7 +743,7 @@ static oci_statement *oci_get_stmt(zval **stmt)
{
oci_statement *statement;
- statement = (oci_statement *) zend_fetch_resource_ex(stmt, -1, "OCI8-Connection", 1, le_stmt);
+ statement = (oci_statement *) zend_fetch_resource(stmt, -1, "OCI8-Connection", NULL, 1, le_stmt);
if (statement && statement->conn->open) {
return statement;
@@ -3233,12 +3233,12 @@ PHP_FUNCTION(ocierror)
OCILS_FETCH();
if (getParametersEx(1, &arg) == SUCCESS) {
- statement = (oci_statement *) zend_fetch_resource_ex(arg, -1, NULL, 1, le_stmt);
+ statement = (oci_statement *) zend_fetch_resource(arg, -1, NULL, NULL, 1, le_stmt);
if (statement) {
errh = statement->pError;
error = statement->error;
} else {
- connection = (oci_connection *) zend_fetch_resource_ex(arg, -1, NULL, 1, le_conn);
+ connection = (oci_connection *) zend_fetch_resource(arg, -1, NULL, NULL, 1, le_conn);
if (connection) {
errh = connection->pError;
error = connection->error;
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 16158bc579..caa41f6665 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -560,8 +560,7 @@ void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
rc = SQLTransact(conn->henv, conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
if(rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
@@ -620,8 +619,7 @@ PHP_FUNCTION(odbc_prepare)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
convert_to_string_ex(pv_query);
query = (*pv_query)->value.str.val;
@@ -922,8 +920,7 @@ PHP_FUNCTION(odbc_exec)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
convert_to_string_ex(pv_query);
query = (*pv_query)->value.str.val;
@@ -1810,8 +1807,7 @@ PHP_FUNCTION(odbc_close)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
zend_list_delete((*pv_conn)->value.lval);
}
@@ -2019,8 +2015,7 @@ PHP_FUNCTION(odbc_autocommit)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
if((*pv_onoff)){
convert_to_long_ex(pv_onoff);
@@ -2087,9 +2082,7 @@ PHP_FUNCTION(odbc_setoption)
switch ((*pv_which)->value.lval) {
case 1: /* SQLSetConnectOption */
- conn = (odbc_connection *) zend_fetch_resource_ex(pv_handle, -1, "ODBC connection",
- 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
if(conn->persistent){
php_error(E_WARNING, "Can't set option for persistent connection");
RETURN_FALSE;
@@ -2156,8 +2149,7 @@ PHP_FUNCTION(odbc_tables)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2239,8 +2231,7 @@ PHP_FUNCTION(odbc_columns)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2318,8 +2309,7 @@ PHP_FUNCTION(odbc_columnprivileges)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2404,8 +2394,7 @@ PHP_FUNCTION(odbc_foreignkeys)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2482,8 +2471,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2556,8 +2544,7 @@ PHP_FUNCTION(odbc_primarykeys)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2638,8 +2625,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2719,8 +2705,7 @@ PHP_FUNCTION(odbc_procedures)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2804,8 +2789,7 @@ PHP_FUNCTION(odbc_specialcolumns)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2890,8 +2874,7 @@ PHP_FUNCTION(odbc_statistics)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
@@ -2968,8 +2951,7 @@ PHP_FUNCTION(odbc_tableprivileges)
WRONG_PARAM_COUNT;
}
- conn = (odbc_connection *)zend_fetch_resource_ex(pv_conn, -1, "ODBC connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
result = (odbc_result *)emalloc(sizeof(odbc_result));
if(result == NULL){
diff --git a/ext/oracle/oracle.c b/ext/oracle/oracle.c
index e0709ca1d5..807d1d771f 100644
--- a/ext/oracle/oracle.c
+++ b/ext/oracle/oracle.c
@@ -577,9 +577,7 @@ PHP_FUNCTION(ora_logoff)
if (getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
zend_list_delete((*arg)->value.lval);
}
@@ -597,9 +595,7 @@ PHP_FUNCTION(ora_open)
if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
if ((cursor = (oraCursor *)emalloc(sizeof(oraCursor))) == NULL){
php_error(E_WARNING, "Out of memory");
@@ -630,11 +626,7 @@ PHP_FUNCTION(ora_close)
if (getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
- cursor = (oraCursor *) zend_fetch_resource_ex(arg, -1, "Oracle-Cursor", 1, le_cursor);
- if (! cursor) {
- RETURN_FALSE;
- }
+ ZEND_FETCH_RESOURCE(cursor, oraCursor *, arg, -1, "Oracle-Cursor", le_cursor);
zend_list_delete((*arg)->value.lval);
@@ -652,9 +644,7 @@ PHP_FUNCTION(ora_commitoff)
if (getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
if (ocof(&conn->lda)) {
php_error(E_WARNING, "Unable to turn off auto-commit (%s)",
@@ -675,8 +665,7 @@ PHP_FUNCTION(ora_commiton)
if (getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
if (ocon(&conn->lda)) {
php_error(E_WARNING, "Unable to turn on auto-commit (%s)",
@@ -697,8 +686,7 @@ PHP_FUNCTION(ora_commit)
if (getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
if (ocom(&conn->lda)) {
php_error(E_WARNING, "Unable to commit transaction (%s)",
@@ -719,8 +707,7 @@ PHP_FUNCTION(ora_rollback)
if (getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
if (orol(&conn->lda)) {
php_error(E_WARNING, "Unable to roll back transaction (%s)",
@@ -984,9 +971,7 @@ PHP_FUNCTION(ora_do)
if (ARG_COUNT(ht) != 2 || getParametersEx(2, &con,&sql) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
- conn = (oraConnection *) zend_fetch_resource_ex(con, -1, "Oracle-Connection", 2, le_conn, le_pconn);
- ZEND_VERIFY_RESOURCE(conn);
+ ZEND_FETCH_RESOURCE2(conn, oraConnection *, con, -1, "Oracle-Connection", le_conn, le_pconn);
convert_to_string_ex(sql);
@@ -1501,21 +1486,22 @@ PHP_FUNCTION(ora_error)
pval **arg;
oraCursor *cursor;
oraConnection *conn;
+ void *res;
+ int what;
if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
+ res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor);
+ ZEND_VERIFY_RESOURCE(res);
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, NULL, 2, le_conn, le_pconn);
- if (conn) {
- RETURN_STRING(ora_error(&conn->lda),1);
+ if (what == le_cursor) {
+ cursor = (oraCursor *) res;
+ RETURN_STRING(ora_error(&cursor->cda),1);
} else {
- cursor = (oraCursor *) zend_fetch_resource_ex(arg, -1, NULL, 1, le_cursor);
- if (cursor) {
- RETURN_STRING(ora_error(&cursor->cda),1);
- }
+ conn = (oraConnection *) res;
+ RETURN_STRING(ora_error(&conn->lda),1);
}
- RETURN_FALSE;
}
/* }}} */
@@ -1526,21 +1512,22 @@ PHP_FUNCTION(ora_errorcode)
pval **arg;
oraCursor *cursor;
oraConnection *conn;
+ void *res;
+ int what;
if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
+ res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor);
+ ZEND_VERIFY_RESOURCE(res);
- conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, NULL, 2, le_conn, le_pconn);
- if (conn) {
- RETURN_LONG(conn->lda.rc);
+ if (what == le_cursor) {
+ cursor = (oraCursor *) res;
+ RETURN_LONG(cursor->cda.rc);
} else {
- cursor = (oraCursor *) zend_fetch_resource_ex(arg, -1, NULL, 1, le_cursor);
- if (cursor) {
- RETURN_LONG(cursor->cda.rc);
- }
+ conn = (oraConnection *) res;
+ RETURN_LONG(conn->lda.rc);
}
- RETURN_FALSE;
}
/* }}} */
@@ -1566,7 +1553,7 @@ ora_get_cursor(HashTable *list, pval **ind)
oraConnection *db_conn;
ORALS_FETCH();
- cursor = (oraCursor *) zend_fetch_resource_ex(ind, -1, "Oracle-Cursor", 1, le_cursor);
+ cursor = (oraCursor *) zend_fetch_resource(ind, -1, "Oracle-Cursor", NULL, 1, le_cursor);
if (! cursor) {
return NULL;
}
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
index abba3e3d20..96d903680f 100644
--- a/ext/sybase_ct/php_sybase_ct.c
+++ b/ext/sybase_ct/php_sybase_ct.c
@@ -642,10 +642,10 @@ PHP_FUNCTION(sybase_close)
break;
}
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(&sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
- zend_list_delete(id);
+ ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", sybase_globals.le_link, sybase_globals.le_plink);
+
+ zend_list_delete(id); /* XXX this IS A BUG!!!! */
RETURN_TRUE;
}
@@ -752,8 +752,7 @@ PHP_FUNCTION(sybase_select_db)
break;
}
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(&sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
+ ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", sybase_globals.le_link, sybase_globals.le_plink);
convert_to_string(db);
cmdbuf = (char *) emalloc(sizeof("use ")+db->value.str.len+1);
@@ -964,8 +963,7 @@ PHP_FUNCTION(sybase_query)
break;
}
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(&sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
+ ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", sybase_globals.le_link, sybase_globals.le_plink);
convert_to_string(query);
@@ -1502,8 +1500,7 @@ PHP_FUNCTION(sybase_affected_rows)
- sybase_ptr = (sybase_link *) zend_fetch_resource_ex(&sybase_link_index, id, "Sybase link", 2, sybase_globals.le_link, sybase_globals.le_plink);
- ZEND_VERIFY_RESOURCE(sybase_ptr);
+ ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, &sybase_link_index, id, "Sybase-Link", sybase_globals.le_link, sybase_globals.le_plink);
return_value->value.lval = sybase_ptr->affected_rows;
return_value->type = IS_LONG;