forked from Lainports/freebsd-ports
make the PHP3 ports work with any version of MySQL, not just 3.23.x. The main (actually, the only) problem was that MySQL 4.x no longer has mysql_drop_db() and mysql_create_db() as separate functions, and just as mentioned in the manual, the solution is to use mysql_query() (or rather, mysql_real_query()) and emulate them.
52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
--- functions/mysql.c.orig Thu Jun 3 13:17:04 2004
|
|
+++ functions/mysql.c Thu Jun 3 13:17:09 2004
|
|
@@ -785,7 +785,9 @@
|
|
void php3_mysql_create_db(INTERNAL_FUNCTION_PARAMETERS)
|
|
{
|
|
pval *db,*mysql_link;
|
|
- int id,type;
|
|
+ int id,type,res;
|
|
+ char *qbuf;
|
|
+ size_t qsize;
|
|
MYSQL *mysql;
|
|
MySQL_TLS_VARS;
|
|
|
|
@@ -818,7 +820,12 @@
|
|
}
|
|
|
|
convert_to_string(db);
|
|
- if (mysql_create_db(mysql,db->value.str.val)==0) {
|
|
+ qsize = strlen(db->value.str.val) + 20;
|
|
+ qbuf = (char *)emalloc(qsize);
|
|
+ snprintf(qbuf, qsize, "CREATE DATABASE %s", db->value.str.val);
|
|
+ res = mysql_real_query(mysql,qbuf,strlen(qbuf));
|
|
+ efree(qbuf);
|
|
+ if (res) {
|
|
RETURN_TRUE;
|
|
} else {
|
|
RETURN_FALSE;
|
|
@@ -831,7 +838,9 @@
|
|
void php3_mysql_drop_db(INTERNAL_FUNCTION_PARAMETERS)
|
|
{
|
|
pval *db,*mysql_link;
|
|
- int id,type;
|
|
+ int id,type,res;
|
|
+ char *qbuf;
|
|
+ size_t qsize;
|
|
MYSQL *mysql;
|
|
MySQL_TLS_VARS;
|
|
|
|
@@ -864,7 +873,12 @@
|
|
}
|
|
|
|
convert_to_string(db);
|
|
- if (mysql_drop_db(mysql,db->value.str.val)==0) {
|
|
+ qsize = strlen(db->value.str.val) + 20;
|
|
+ qbuf = (char *)emalloc(qsize);
|
|
+ snprintf(qbuf, qsize, "DROP DATABASE %s", db->value.str.val);
|
|
+ res = mysql_real_query(mysql,qbuf,strlen(qbuf));
|
|
+ efree(qbuf);
|
|
+ if (res) {
|
|
RETURN_TRUE;
|
|
} else {
|
|
RETURN_FALSE;
|