cvs: php4 /ext/mysql php_mysql.c

From: Date: Tue, 07 Nov 2000 15:46:15 +0000
Subject: cvs: php4 /ext/mysql php_mysql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2515@lists.php.net to get a copy of this message
stas Tue Nov 7 07:46:15 2000 EDT Modified files: /php4/ext/mysql php_mysql.c Log: Enable to use mysql_use_result in query functions. You may need this if you use real big queries. @- Allow user to use mysql_use_result in mysql queries (Stas) Index: php4/ext/mysql/php_mysql.c diff -u php4/ext/mysql/php_mysql.c:1.58 php4/ext/mysql/php_mysql.c:1.59 --- php4/ext/mysql/php_mysql.c:1.58 Thu Nov 2 17:56:47 2000 +++ php4/ext/mysql/php_mysql.c Tue Nov 7 07:46:15 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mysql.c,v 1.58 2000/11/03 01:56:47 zeev Exp $ */ +/* $Id: php_mysql.c,v 1.59 2000/11/07 15:46:15 stas Exp $ */ /* TODO: @@ -77,6 +77,9 @@ #define MYSQL_NUM 1<<1 #define MYSQL_BOTH (MYSQL_ASSOC|MYSQL_NUM) +#define MYSQL_USE_RESULT 0 +#define MYSQL_STORE_RESULT 1 + #if MYSQL_VERSION_ID < 32224 #define PHP_MYSQL_VALID_RESULT(mysql) \ (mysql_num_fields(mysql)>0) @@ -270,6 +273,8 @@ REGISTER_LONG_CONSTANT("MYSQL_NUM", MYSQL_NUM, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQL_BOTH", MYSQL_BOTH, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQL_USE_RESULT", MYSQL_USE_RESULT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQL_STORE_RESULT", MYSQL_STORE_RESULT, CONST_CS | CONST_PERSISTENT); return SUCCESS; } @@ -742,12 +747,12 @@ /* }}} */ -/* {{{ proto int mysql_query(string query [, int link_identifier]) +/* {{{ proto int mysql_query(string query [, int link_identifier] [, int result_mode]) Send an SQL query to MySQL */ PHP_FUNCTION(mysql_query) { - pval **query, **mysql_link; - int id; + pval **query, **mysql_link, **store_result; + int id,use_store=MYSQL_STORE_RESULT; MYSQL *mysql; MYSQL_RES *mysql_result; MySLS_FETCH(); @@ -766,6 +771,16 @@ } id = -1; break; + case 3: + if(zend_get_parameters_ex(3, &query, &mysql_link, &store_result)==FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(store_result); + if(Z_LVAL_PP(store_result) == MYSQL_USE_RESULT) { + use_store = MYSQL_USE_RESULT; + } + id = -1; + break; default: WRONG_PARAM_COUNT; break; @@ -784,7 +799,12 @@ RETURN_FALSE; } #endif - if ((mysql_result=mysql_store_result(mysql))==NULL) { + if(use_store == MYSQL_USE_RESULT) { + mysql_result=mysql_use_result(mysql); + } else { + mysql_result=mysql_store_result(mysql); + } + if (mysql_result==NULL) { if (PHP_MYSQL_VALID_RESULT(mysql)) { /* query should have returned rows */ php_error(E_WARNING, "MySQL: Unable to save result set"); RETURN_FALSE; @@ -797,12 +817,12 @@ /* }}} */ -/* {{{ proto int mysql_db_query(string database_name, string query [, int link_identifier]) +/* {{{ proto int mysql_db_query(string database_name, string query [, int link_identifier] [, int result_mode]) Send an SQL query to MySQL */ PHP_FUNCTION(mysql_db_query) { - pval **db, **query, **mysql_link; - int id; + pval **db, **query, **mysql_link, **store_result; + int id,use_store=MYSQL_STORE_RESULT; MYSQL *mysql; MYSQL_RES *mysql_result; MySLS_FETCH(); @@ -821,6 +841,16 @@ } id = -1; break; + case 4: + if(zend_get_parameters_ex(4, &db, &query, &mysql_link, &store_result)==FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(store_result); + if(Z_LVAL_PP(store_result) == MYSQL_USE_RESULT) { + use_store = MYSQL_USE_RESULT; + } + id = -1; + break; default: WRONG_PARAM_COUNT; break; @@ -844,7 +874,12 @@ RETURN_FALSE; } #endif - if ((mysql_result=mysql_store_result(mysql))==NULL) { + if(use_store == MYSQL_USE_RESULT) { + mysql_result=mysql_use_result(mysql); + } else { + mysql_result=mysql_store_result(mysql); + } + if (mysql_result==NULL) { if (PHP_MYSQL_VALID_RESULT(mysql)) { /* query should have returned rows */ php_error(E_WARNING, "MySQL: Unable to save result set"); RETURN_FALSE;

« previous php.cvs (#2515) next »