Date: 12/19/98
- Next message: sas: "[PHP-DEV] CVS update: php3/tests"
- Previous message: Rasmus Lerdorf: "[PHP-DEV] 3.0.6 tarball rolled"
- Next in thread: sas: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Saturday December 19, 1998 @ 21:29
Author: sas
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv27786/functions
Modified Files:
msql.c php3_msql.h
Log Message:
major clean up of mSQL module
- reduced code size by using some macros
- storing results not by result id, but by query id
- affected rows support
- documentation correction
- tests/msql.php3 has some simple tests
Index: php3/functions/msql.c
diff -c php3/functions/msql.c:1.99 php3/functions/msql.c:1.100
*** php3/functions/msql.c:1.99 Tue Dec 15 08:36:03 1998
--- php3/functions/msql.c Sat Dec 19 21:29:24 1998
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: msql.c,v 1.99 1998/12/15 13:36:03 rasmus Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: msql.c,v 1.100 1998/12/20 02:29:24 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 45,52 ****
#include "functions/reg.h"
#include "php3_string.h"
-
-
#if HAVE_MSQL
#if defined(WIN32) && defined(MSQL1)
--- 45,50 ----
***************
*** 105,110 ****
--- 103,109 ----
{"msql_fieldtype", php3_msql_field_type, NULL},
{"msql_fieldflags", php3_msql_field_flags, NULL},
{"msql_regcase", php3_sql_regcase, NULL},
+ {"msql_affected_rows", php3_msql_affected_rows, NULL},
/* for downwards compatability */
{"msql", php3_msql_db_query, NULL},
{"msql_selectdb", php3_msql_select_db, NULL},
***************
*** 158,164 ****
--- 157,199 ----
#endif
#endif
+ typedef struct {
+ m_result *result;
+ int af_rows;
+ } m_query;
+
+ #define MSQL_GET_QUERY(res) \
+ convert_to_long((res)); \
+ msql_query = (m_query *) php3_list_find((res)->value.lval,&type); \
+ if (type!=MSQL_GLOBAL(php3_msql_module).le_query) { \
+ php3_error(E_WARNING,"%d is not a mSQL query index", \
+ res->value.lval); \
+ RETURN_FALSE; \
+ } \
+ msql_result = msql_query->result
+
+ static void _delete_query(void *arg)
+ {
+ m_query *query = (m_query *) arg;
+
+ if(query->result) msqlFreeResult(query->result);
+ efree(arg);
+ }
+
+ #define _new_query(a,b) \
+ __new_query(INTERNAL_FUNCTION_PARAM_PASSTHRU,a,b)
+ static int __new_query(INTERNAL_FUNCTION_PARAMETERS, m_result *res, int af_rows)
+ {
+ m_query *query = (m_query *) emalloc(sizeof(m_query));
+
+ query->result = res;
+ query->af_rows = af_rows;
+
+ return (php3_list_insert((void *) query,
+ MSQL_GLOBAL(php3_msql_module).le_query));
+ }
+
static void _close_msql_link(int link)
{
MSQL_TLS_VARS;
***************
*** 175,181 ****
MSQL_GLOBAL(php3_msql_module).num_links--;
}
-
DLEXPORT int php3_minit_msql(INIT_FUNC_ARGS)
{
#ifdef THREAD_SAFE
--- 210,215 ----
***************
*** 205,211 ****
MSQL_GLOBAL(php3_msql_module).max_links=-1;
}
MSQL_GLOBAL(php3_msql_module).num_persistent=0;
! MSQL_GLOBAL(php3_msql_module).le_result = register_list_destructors(msqlFreeResult,NULL);
MSQL_GLOBAL(php3_msql_module).le_link = register_list_destructors(_close_msql_link,NULL);
MSQL_GLOBAL(php3_msql_module).le_plink = register_list_destructors(NULL,_close_msql_plink);
--- 239,245 ----
MSQL_GLOBAL(php3_msql_module).max_links=-1;
}
MSQL_GLOBAL(php3_msql_module).num_persistent=0;
! MSQL_GLOBAL(php3_msql_module).le_query = register_list_destructors(_delete_query,NULL);
MSQL_GLOBAL(php3_msql_module).le_link = register_list_destructors(_close_msql_link,NULL);
MSQL_GLOBAL(php3_msql_module).le_plink = register_list_destructors(NULL,_close_msql_plink);
***************
*** 413,419 ****
MSQL_GLOBAL(php3_msql_module).default_link=return_value->value.lval;
}
-
static int php3_msql_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
{
MSQL_TLS_VARS;
--- 447,452 ----
***************
*** 616,622 ****
pval *query,*msql_link;
int id,type;
int msql;
! m_result *msql_result;
MSQL_TLS_VARS;
switch(ARG_COUNT(ht)) {
--- 649,655 ----
pval *query,*msql_link;
int id,type;
int msql;
! int af_rows;
MSQL_TLS_VARS;
switch(ARG_COUNT(ht)) {
***************
*** 645,662 ****
}
convert_to_string(query);
! if (msqlQuery(msql,query->value.str.val)==-1) {
! RETURN_FALSE;
! }
! if ((msql_result=msqlStoreResult())==NULL) {
! /*
! php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
- */
- RETURN_TRUE;
}
! return_value->value.lval = php3_list_insert(msql_result,MSQL_GLOBAL(php3_msql_module).le_result);
! return_value->type = IS_LONG;
}
/* }}} */
--- 678,687 ----
}
convert_to_string(query);
! if ((af_rows = msqlQuery(msql,query->value.str.val))==-1) {
RETURN_FALSE;
}
! RETVAL_LONG(_new_query(msqlStoreResult(), af_rows));
}
/* }}} */
***************
*** 667,673 ****
pval *db,*query,*msql_link;
int id,type;
int msql;
! m_result *msql_result;
MSQL_TLS_VARS;
switch(ARG_COUNT(ht)) {
--- 692,698 ----
pval *db,*query,*msql_link;
int id,type;
int msql;
! int af_rows;
MSQL_TLS_VARS;
switch(ARG_COUNT(ht)) {
***************
*** 701,718 ****
}
convert_to_string(query);
! if (msqlQuery(msql,query->value.str.val)==-1) {
! RETURN_FALSE;
! }
! if ((msql_result=msqlStoreResult())==NULL) {
! /*
! php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
- */
- RETURN_TRUE;
}
! return_value->value.lval = php3_list_insert(msql_result,MSQL_GLOBAL(php3_msql_module).le_result);
! return_value->type = IS_LONG;
}
/* }}} */
--- 726,735 ----
}
convert_to_string(query);
! if ((af_rows = msqlQuery(msql,query->value.str.val))==-1) {
RETURN_FALSE;
}
! RETVAL_LONG(_new_query(msqlStoreResult(), af_rows));
}
/* }}} */
***************
*** 751,758 ****
php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
}
! return_value->value.lval = php3_list_insert(msql_result,MSQL_GLOBAL(php3_msql_module).le_result);
! return_value->type = IS_LONG;
}
/* }}} */
--- 768,774 ----
php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
}
! RETVAL_LONG(_new_query(msql_result, 0));
}
/* }}} */
***************
*** 799,806 ****
php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
}
! return_value->value.lval = php3_list_insert(msql_result,MSQL_GLOBAL(php3_msql_module).le_result);
! return_value->type = IS_LONG;
}
/* }}} */
--- 815,821 ----
php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
}
! RETVAL_LONG(_new_query(msql_result, 0));
}
/* }}} */
***************
*** 848,855 ****
php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
}
! return_value->value.lval = php3_list_insert(msql_result,MSQL_GLOBAL(php3_msql_module).le_result);
! return_value->type = IS_LONG;
}
/* }}} */
--- 863,869 ----
php3_error(E_WARNING,"Unable to save mSQL query result");
RETURN_FALSE;
}
! RETVAL_LONG(_new_query(msql_result, 0));
}
/* }}} */
***************
*** 864,880 ****
}
/* }}} */
! /* {{{ proto int msql_result(int result, int row [, mixed field])
Get result data */
DLEXPORT void php3_msql_result(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result, *row, *field=NULL;
m_result *msql_result;
m_row sql_row;
int type,field_offset=0;
MSQL_TLS_VARS;
-
switch (ARG_COUNT(ht)) {
case 2:
if (getParameters(ht, 2, &result, &row)==FAILURE) {
--- 878,894 ----
}
/* }}} */
! /* {{{ proto int msql_result(int query, int row [, mixed field])
Get result data */
DLEXPORT void php3_msql_result(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result, *row, *field=NULL;
m_result *msql_result;
+ m_query *msql_query;
m_row sql_row;
int type,field_offset=0;
MSQL_TLS_VARS;
switch (ARG_COUNT(ht)) {
case 2:
if (getParameters(ht, 2, &result, &row)==FAILURE) {
***************
*** 890,907 ****
WRONG_PARAM_COUNT;
break;
}
-
- convert_to_long(result);
- msql_result = (m_result *) php3_list_find(result->value.lval,&type);
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
! RETURN_FALSE;
! }
convert_to_long(row);
if (row->value.lval<0 || row->value.lval>=msqlNumRows(msql_result)) {
! php3_error(E_WARNING,"Unable to jump to row %d on mSQL result index %d",row->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlDataSeek(msql_result,row->value.lval);
--- 904,915 ----
WRONG_PARAM_COUNT;
break;
}
! MSQL_GET_QUERY(result);
convert_to_long(row);
if (row->value.lval<0 || row->value.lval>=msqlNumRows(msql_result)) {
! php3_error(E_WARNING,"Unable to jump to row %d on mSQL query index %d",row->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlDataSeek(msql_result,row->value.lval);
***************
*** 933,939 ****
i++;
}
if (!tmp_field) { /* no match found */
! php3_error(E_WARNING,"%s%s%s not found in mSQL result index %d",
(table_name?table_name:""), (table_name?".":""), field_name, result->value.lval);
efree(field_name);
if (table_name) {
--- 941,947 ----
i++;
}
if (!tmp_field) { /* no match found */
! php3_error(E_WARNING,"%s%s%s not found in mSQL query index %d",
(table_name?table_name:""), (table_name?".":""), field_name, result->value.lval);
efree(field_name);
if (table_name) {
***************
*** 973,984 ****
}
/* }}} */
! /* {{{ proto int msql_num_rows(int result)
Get number of rows in a result */
DLEXPORT void php3_msql_num_rows(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
int type;
MSQL_TLS_VARS;
--- 981,993 ----
}
/* }}} */
! /* {{{ proto int msql_num_rows(int query)
Get number of rows in a result */
DLEXPORT void php3_msql_num_rows(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
***************
*** 986,1037 ****
WRONG_PARAM_COUNT;
}
! convert_to_long(result);
! msql_result = (m_result *) php3_list_find(result->value.lval,&type);
!
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
! RETURN_FALSE;
! }
!
! return_value->value.lval = msqlNumRows(msql_result);
! return_value->type = IS_LONG;
}
/* }}} */
! /* {{{ proto int msql_num_fields(int result)
Get number of fields in a result */
DLEXPORT void php3_msql_num_fields(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
int type;
MSQL_TLS_VARS;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
WRONG_PARAM_COUNT;
}
-
- convert_to_long(result);
- msql_result = (m_result *) php3_list_find(result->value.lval,&type);
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
! RETURN_FALSE;
! }
!
! return_value->value.lval = msqlNumFields(msql_result);
! return_value->type = IS_LONG;
}
/* }}} */
! /* {{{ proto array msql_fetch_row(int result)
Get a result row as an enumerated array */
DLEXPORT void php3_msql_fetch_row(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
m_row msql_row;
int type;
int num_fields;
int i;
--- 995,1032 ----
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
! RETVAL_LONG(msql_result ? msqlNumRows(msql_result) : 0);
}
/* }}} */
! /* {{{ proto int msql_num_fields(int query)
Get number of fields in a result */
DLEXPORT void php3_msql_num_fields(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
! RETVAL_LONG(msql_result ? msqlNumFields(msql_result) : 0);
}
/* }}} */
! /* {{{ proto array msql_fetch_row(int query)
Get a result row as an enumerated array */
DLEXPORT void php3_msql_fetch_row(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
m_row msql_row;
+ m_query *msql_query;
int type;
int num_fields;
int i;
***************
*** 1040,1059 ****
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
WRONG_PARAM_COUNT;
}
-
- convert_to_long(result);
- msql_result = (m_result *) php3_list_find(result->value.lval,&type);
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
RETURN_FALSE;
}
- if ((msql_row=msqlFetchRow(msql_result))==NULL) {
- RETURN_FALSE;
- }
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
num_fields = msqlNumFields(msql_result);
for (i=0; i<num_fields; i++) {
--- 1035,1047 ----
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
! if (!msql_result ||
! ((msql_row = msqlFetchRow(msql_result)) == NULL) ||
! (array_init(return_value)==FAILURE)) {
RETURN_FALSE;
}
num_fields = msqlNumFields(msql_result);
for (i=0; i<num_fields; i++) {
***************
*** 1072,1077 ****
--- 1060,1066 ----
m_result *msql_result;
m_row msql_row;
m_field *msql_field;
+ m_query *msql_query;
int type;
int num_fields;
int i;
***************
*** 1082,1095 ****
WRONG_PARAM_COUNT;
}
! convert_to_long(result);
! msql_result = (m_result *) php3_list_find(result->value.lval,&type);
!
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
! RETURN_FALSE;
! }
! if ((msql_row=msqlFetchRow(msql_result))==NULL) {
RETURN_FALSE;
}
--- 1071,1078 ----
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
! if (!msql_result || (msql_row=msqlFetchRow(msql_result))==NULL) {
RETURN_FALSE;
}
***************
*** 1114,1120 ****
}
}
! /* {{{ proto object msql_fetch_object(int result)
Fetch a result row as an object */
DLEXPORT void php3_msql_fetch_object(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1097,1103 ----
}
}
! /* {{{ proto object msql_fetch_object(int query)
Fetch a result row as an object */
DLEXPORT void php3_msql_fetch_object(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1125,1131 ****
}
/* }}} */
! /* {{{ proto array msql_fetch_array(int result)
Fetch a result row as an associative array */
DLEXPORT void php3_msql_fetch_array(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1108,1114 ----
}
/* }}} */
! /* {{{ proto array msql_fetch_array(int query)
Fetch a result row as an associative array */
DLEXPORT void php3_msql_fetch_array(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1133,1144 ****
}
/* }}} */
! /* {{{ proto int msql_data_seek(int result, int row_number)
Move internal result pointer */
DLEXPORT void php3_msql_data_seek(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result,*offset;
m_result *msql_result;
int type;
MSQL_TLS_VARS;
--- 1116,1128 ----
}
/* }}} */
! /* {{{ proto int msql_data_seek(int query, int row_number)
Move internal result pointer */
DLEXPORT void php3_msql_data_seek(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result,*offset;
m_result *msql_result;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
***************
*** 1146,1161 ****
WRONG_PARAM_COUNT;
}
! convert_to_long(result);
! msql_result = (m_result *) php3_list_find(result->value.lval,&type);
!
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
! RETURN_FALSE;
! }
convert_to_long(offset);
! if (offset->value.lval<0 || offset->value.lval>=msqlNumRows(msql_result)) {
! php3_error(E_WARNING,"Offset %d is invalid for mSQL result index %d",offset->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlDataSeek(msql_result,offset->value.lval);
--- 1130,1141 ----
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
convert_to_long(offset);
! if (!msql_result ||
! offset->value.lval<0 ||
! offset->value.lval>=msqlNumRows(msql_result)) {
! php3_error(E_WARNING,"Offset %d is invalid for mSQL query index %d",offset->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlDataSeek(msql_result,offset->value.lval);
***************
*** 1201,1213 ****
}
}
! /* {{{ proto object msql_fetch_field(int result [, int field_offset])
Get column information from a result and return as an object */
DLEXPORT void php3_msql_fetch_field(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result, *field=NULL;
m_result *msql_result;
m_field *msql_field;
int type;
MSQL_TLS_VARS;
--- 1181,1194 ----
}
}
! /* {{{ proto object msql_fetch_field(int query [, int field_offset])
Get column information from a result and return as an object */
DLEXPORT void php3_msql_fetch_field(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result, *field=NULL;
m_result *msql_result;
m_field *msql_field;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
***************
*** 1226,1239 ****
WRONG_PARAM_COUNT;
}
! convert_to_long(result);
! msql_result = (m_result *) php3_list_find(result->value.lval,&type);
- if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
- php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
- RETURN_FALSE;
- }
-
if (field) {
if (field->value.lval<0 || field->value.lval>=msqlNumRows(msql_result)) {
php3_error(E_NOTICE,"mSQL: Bad field offset specified");
--- 1207,1214 ----
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
if (field) {
if (field->value.lval<0 || field->value.lval>=msqlNumRows(msql_result)) {
php3_error(E_NOTICE,"mSQL: Bad field offset specified");
***************
*** 1241,1247 ****
}
msqlFieldSeek(msql_result,field->value.lval);
}
! if ((msql_field=msqlFetchField(msql_result))==NULL) {
RETURN_FALSE;
}
if (object_init(return_value)==FAILURE) {
--- 1216,1222 ----
}
msqlFieldSeek(msql_result,field->value.lval);
}
! if (!msql_result || (msql_field=msqlFetchField(msql_result))==NULL) {
RETURN_FALSE;
}
if (object_init(return_value)==FAILURE) {
***************
*** 1261,1272 ****
}
/* }}} */
! /* {{{ proto int msql_field_seek(int result, int field_offset)
Set result pointer to a specific field offset */
DLEXPORT void php3_msql_field_seek(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result, *offset;
m_result *msql_result;
int type;
MSQL_TLS_VARS;
--- 1236,1248 ----
}
/* }}} */
! /* {{{ proto int msql_field_seek(int query, int field_offset)
Set result pointer to a specific field offset */
DLEXPORT void php3_msql_field_seek(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result, *offset;
m_result *msql_result;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
***************
*** 1274,1289 ****
WRONG_PARAM_COUNT;
}
! convert_to_long(result);
! msql_result = (m_result *) php3_list_find(result->value.lval,&type);
!
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
RETURN_FALSE;
}
- convert_to_long(offset);
if (offset->value.lval<0 || offset->value.lval>=msqlNumFields(msql_result)) {
! php3_error(E_WARNING,"Field %d is invalid for mSQL result index %d",offset->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlFieldSeek(msql_result,offset->value.lval);
--- 1250,1263 ----
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
! convert_to_long(offset);
! if(!msql_result) {
RETURN_FALSE;
}
if (offset->value.lval<0 || offset->value.lval>=msqlNumFields(msql_result)) {
! php3_error(E_WARNING,"Field %d is invalid for mSQL query index %d",
! offset->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlFieldSeek(msql_result,offset->value.lval);
***************
*** 1302,1325 ****
pval *result, *field;
m_result *msql_result;
m_field *msql_field;
int type;
MSQL_TLS_VARS;
if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
WRONG_PARAM_COUNT;
}
-
- convert_to_long(result);
- msql_result = (m_result *) php3_list_find(result->value.lval,&type);
! if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
! php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
RETURN_FALSE;
}
-
convert_to_long(field);
if (field->value.lval<0 || field->value.lval>=msqlNumFields(msql_result)) {
! php3_error(E_WARNING,"Field %d is invalid for mSQL result index %d",field->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlFieldSeek(msql_result,field->value.lval);
--- 1276,1296 ----
pval *result, *field;
m_result *msql_result;
m_field *msql_field;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
WRONG_PARAM_COUNT;
}
! MSQL_GET_QUERY(result);
! if(!msql_result) {
RETURN_FALSE;
}
convert_to_long(field);
if (field->value.lval<0 || field->value.lval>=msqlNumFields(msql_result)) {
! php3_error(E_WARNING,"Field %d is invalid for mSQL query index %d",field->value.lval,result->value.lval);
RETURN_FALSE;
}
msqlFieldSeek(msql_result,field->value.lval);
***************
*** 1387,1393 ****
}
}
! /* {{{ proto string msql_field_name(int result, int field_index)
Get the name of the specified field in a result */
DLEXPORT void php3_msql_field_name(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1358,1364 ----
}
}
! /* {{{ proto string msql_field_name(int query, int field_index)
Get the name of the specified field in a result */
DLEXPORT void php3_msql_field_name(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1395,1401 ****
}
/* }}} */
! /* {{{ proto string msql_field_table(int result, int field_offset)
Get name of the table the specified field is in */
DLEXPORT void php3_msql_field_table(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1366,1372 ----
}
/* }}} */
! /* {{{ proto string msql_field_table(int query, int field_offset)
Get name of the table the specified field is in */
DLEXPORT void php3_msql_field_table(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1403,1409 ****
}
/* }}} */
! /* {{{ proto int msql_field_len(int result, int field_offet)
Returns the length of the specified field */
DLEXPORT void php3_msql_field_len(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1374,1380 ----
}
/* }}} */
! /* {{{ proto int msql_field_len(int query, int field_offet)
Returns the length of the specified field */
DLEXPORT void php3_msql_field_len(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1411,1417 ****
}
/* }}} */
! /* {{{ proto string msql_field_type(int result, int field_offset)
Get the type of the specified field in a result */
DLEXPORT void php3_msql_field_type(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1382,1388 ----
}
/* }}} */
! /* {{{ proto string msql_field_type(int query, int field_offset)
Get the type of the specified field in a result */
DLEXPORT void php3_msql_field_type(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1419,1425 ****
}
/* }}} */
! /* {{{ proto string msql_field_flags(int result, int field_offset)
Get the flags associated with the specified field in a result */
DLEXPORT void php3_msql_field_flags(INTERNAL_FUNCTION_PARAMETERS)
{
--- 1390,1396 ----
}
/* }}} */
! /* {{{ proto string msql_field_flags(int query, int field_offset)
Get the flags associated with the specified field in a result */
DLEXPORT void php3_msql_field_flags(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1428,1458 ****
/* }}} */
! /* {{{ proto int msql_free_result(int result)
Free result memory */
DLEXPORT void php3_msql_free_result(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
int type;
MSQL_TLS_VARS;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
WRONG_PARAM_COUNT;
- }
-
- convert_to_long(result);
- if (result->value.lval==0) {
- RETURN_FALSE;
- }
- msql_result = (m_result *) php3_list_find(result->value.lval,&type);
-
- if (type!=MSQL_GLOBAL(php3_msql_module).le_result) {
- php3_error(E_WARNING,"%d is not a mSQL result index",result->value.lval);
- RETURN_FALSE;
}
php3_list_delete(result->value.lval);
RETURN_TRUE;
}
/* }}} */
--- 1399,1439 ----
/* }}} */
! /* {{{ proto int msql_free_result(int query)
Free result memory */
DLEXPORT void php3_msql_free_result(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
m_result *msql_result;
+ m_query *msql_query;
int type;
MSQL_TLS_VARS;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
WRONG_PARAM_COUNT;
}
+
+ MSQL_GET_QUERY(result);
php3_list_delete(result->value.lval);
RETURN_TRUE;
+ }
+ /* }}} */
+
+ /* {{{ proto int msql_affected_rows(int query)
+ Return number of affected rows */
+ DLEXPORT void php3_msql_affected_rows(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *result;
+ m_result *msql_result;
+ m_query *msql_query;
+ int type;
+ MSQL_TLS_VARS;
+
+ if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &result) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ MSQL_GET_QUERY(result);
+ RETVAL_LONG(msql_query->af_rows);
}
/* }}} */
Index: php3/functions/php3_msql.h
diff -c php3/functions/php3_msql.h:1.23 php3/functions/php3_msql.h:1.24
*** php3/functions/php3_msql.h:1.23 Fri May 15 06:57:33 1998
--- php3/functions/php3_msql.h Sat Dec 19 21:29:25 1998
***************
*** 28,34 ****
*/
! /* $Id: php3_msql.h,v 1.23 1998/05/15 10:57:33 zeev Exp $ */
#ifndef _PHP3_MSQL_H
#define _PHP3_MSQL_H
--- 28,34 ----
*/
! /* $Id: php3_msql.h,v 1.24 1998/12/20 02:29:25 sas Exp $ */
#ifndef _PHP3_MSQL_H
#define _PHP3_MSQL_H
***************
*** 59,64 ****
--- 59,65 ----
extern DLEXPORT void php3_msql_list_tables(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_list_fields(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_error(INTERNAL_FUNCTION_PARAMETERS);
+ extern DLEXPORT void php3_msql_affected_rows(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_query(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_db_query(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_result(INTERNAL_FUNCTION_PARAMETERS);
***************
*** 82,88 ****
long num_links,num_persistent;
long max_links,max_persistent;
long allow_persistent;
! int le_result;
int le_link;
int le_plink;
} msql_module;
--- 83,89 ----
long num_links,num_persistent;
long max_links,max_persistent;
long allow_persistent;
! int le_query;
int le_link;
int le_plink;
} msql_module;
-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: sas: "[PHP-DEV] CVS update: php3/tests"
- Previous message: Rasmus Lerdorf: "[PHP-DEV] 3.0.6 tarball rolled"
- Next in thread: sas: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

