cvs: php4 /ext/mysql php_mysql.c
| From: | Georg Richter | Date: | Sun, 21 Jul 2002 21:36:10 +0000 |
| Subject: | cvs: php4 /ext/mysql php_mysql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12924@lists.php.net to get a copy of this message | ||
georg Sun Jul 21 17:36:10 2002 EDT
Modified files:
/php4/ext/mysql php_mysql.c
Log:
removed changes for mysql_select_db (optional parameter)
Why:
1) Its not the common way to add additionally functionality for functions or
features which are already implemented in SQL. Therefore also a lot of
mysql functions are marked as deprecated (and will be removed in near future)
2) The implemented workaround works only when mysql_select_db was called
before (fetching the databasename from mysql->conn.db). It returns invalid
or inconsistent results e.g.:
- when "USE databasename" via mysql_query was used
- when database was dropped or grant privileges had changed.
In conjunction with persistent connection, there are also some inconsistencies,
cause mysql_select_db returns the databasename from an old connection.
To determine the database name just use the SQL command "SELECT DATABASE()"
Index: php4/ext/mysql/php_mysql.c
diff -u php4/ext/mysql/php_mysql.c:1.146 php4/ext/mysql/php_mysql.c:1.147
--- php4/ext/mysql/php_mysql.c:1.146 Sun Jul 21 16:16:03 2002
+++ php4/ext/mysql/php_mysql.c Sun Jul 21 17:36:10 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mysql.c,v 1.146 2002/07/21 20:16:03 georg Exp $ */
+/* $Id: php_mysql.c,v 1.147 2002/07/21 21:36:10 georg Exp $ */
/* TODO:
*
@@ -833,14 +833,13 @@
}
/* }}} */
-/* {{{ proto bool mysql_select_db(string database_name [, int link_identifier [, bool
return_prev_dbname]])
+/* {{{ proto bool mysql_select_db(string database_name [, int link_identifier])
Selects a MySQL database */
PHP_FUNCTION(mysql_select_db)
{
- zval **db, **mysql_link, **ret_prevdb;
- int id, ret_dbname=0;
+ zval **db, **mysql_link;
+ int id;
php_mysql_conn *mysql;
- char *prev_db=NULL;
switch(ZEND_NUM_ARGS()) {
case 1:
@@ -856,14 +855,6 @@
}
id = -1;
break;
- case 3:
- if (zend_get_parameters_ex(3, &db, &mysql_link, &ret_prevdb)==FAILURE) {
- RETURN_FALSE;
- }
- id = -1;
- convert_to_long_ex(ret_prevdb);
- ret_dbname = Z_LVAL_PP(ret_prevdb);
- break;
default:
WRONG_PARAM_COUNT;
break;
@@ -873,21 +864,10 @@
convert_to_string_ex(db);
- /* Get the previous database name */
- if (ret_dbname && mysql->conn.db) {
- prev_db=estrdup(mysql->conn.db);
- }
-
if (mysql_select_db(&mysql->conn, Z_STRVAL_PP(db))!=0) {
RETVAL_FALSE;
- } else if (prev_db) {
- RETVAL_STRING(prev_db, 1);
} else {
RETVAL_TRUE;
- }
-
- if (prev_db) {
- efree(prev_db);
}
}
/* }}} */