if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &flag) == FAILURE) {
return;
}
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
- if (Z_LVAL_P(pv_res)) {
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
- if (mode) {
- result->longreadlen = flag;
- } else {
- result->binmode = flag;
- }
+ if (mode) {
+ result->longreadlen = flag;
} else {
- if (mode) {
- ODBCG(defaultlrl) = flag;
- } else {
- ODBCG(defaultbinmode) = flag;
- }
+ result->binmode = flag;
}
+
RETURN_TRUE;
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
rc = SQLTransact(conn->henv, conn->hdbc, (SQLUSMALLINT)((type)?SQL_COMMIT:SQL_ROLLBACK));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
Z_ADDREF_P(pv_conn);
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
/* XXX check for already bound parameters*/
if (result->numparams > 0 && numArgs == 1) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
rc = SQLGetInfo(result->conn_ptr->hdbc,SQL_MAX_CURSOR_NAME_LEN, (void *)&max_len,sizeof(max_len),&len);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, zv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(zv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
/* now we have the "connection" lets call the DataSource object */
rc = SQLDataSources(conn->henv,
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
Z_ADDREF_P(pv_conn);
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
}
#endif
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
}
#endif /* HAVE_SQL_EXTENDED_FETCH */
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
rownum = pv_row;
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
field_ind = Z_LVAL_P(pv_field) - 1;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if ((result->numcols == 0)) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
+
if (result->values) {
for (i = 0; i < result->numcols; i++) {
if (result->values[i].value) {
}
ODBCG(num_persistent)++;
ODBCG(num_links)++;
- db_conn->res = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_pconn);
+ db_conn->res = zend_register_resource(db_conn, le_pconn);
+ RETVAL_RES(db_conn->res);
} else { /* found connection */
if (le->type != le_pconn) {
RETURN_FALSE;
}
}
}
- db_conn->res = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_pconn);
+ db_conn->res = zend_register_resource(db_conn, le_pconn);
+ RETVAL_RES(db_conn->res);
} else { /* non persistent */
zend_resource *index_ptr, new_index_ptr;
efree(hashed_details);
RETURN_FALSE;
}
- db_conn->res = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_conn);
- new_index_ptr.ptr = (void *) Z_RES_HANDLE_P(return_value);
+ db_conn->res = zend_register_resource(db_conn, le_conn);
+ RETVAL_RES(db_conn->res);
+ new_index_ptr.ptr = (void *)(zend_uintptr_t)Z_RES_HANDLE_P(return_value);
new_index_ptr.type = le_index_ptr;
if (zend_hash_str_update_mem(&EG(regular_list), hashed_details, hashed_len, (void *) &new_index_ptr,
odbc_connection *conn;
odbc_result *res;
int is_pconn = 0;
- int found_resource_type = le_conn;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_conn) == FAILURE) {
return;
}
- conn = (odbc_connection *) zend_fetch_resource(pv_conn, -1, "ODBC-Link", &found_resource_type, 2, le_conn, le_pconn);
- if (found_resource_type==le_pconn) {
+ conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn);
+ if (Z_RES_P(pv_conn)->type == le_pconn) {
is_pconn = 1;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
+
SQLRowCount(result->stmt, &rows);
RETURN_LONG(rows);
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->values) {
for(i = 0; i < result->numcols; i++) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
+
RETURN_LONG(result->numcols);
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
if (ZEND_NUM_ARGS() > 1) {
rc = SQLSetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (pv_onoff) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
}
if (ZEND_NUM_ARGS() == 1) {
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
ptr = zend_string_alloc(len + 1, 0);
if (mode == 0) {
strlcpy(ptr->val, conn->laststate, len+1);
switch (pv_which) {
case 1: /* SQLSetConnectOption */
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
if (conn->persistent) {
php_error_docref(NULL, E_WARNING, "Unable to set option for persistent connection");
}
break;
case 2: /* SQLSetStmtOption */
- ZEND_FETCH_RESOURCE(result, odbc_result *, pv_handle, -1, "ODBC result", le_result);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
rc = SQLSetStmtOption(result->stmt, (unsigned short) pv_opt, pv_val);
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_DBMAKER || HAVE_SOLID*/
EMPTY_TO_NULL(ftable);
#endif
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_SOLID */
data_type = (SQLSMALLINT) pv_data_type;
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_SOLID */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_SOLID */
scope = (SQLUSMALLINT) vscope;
nullable = (SQLUSMALLINT) vnullable;
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
unique = (SQLUSMALLINT) vunique;
reserved = (SQLUSMALLINT) vreserved;
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_DBMAKER */