From a22b830c9ce5dbbcb77b56119cd7c21a1a97473e Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 27 Oct 2005 17:33:43 +0000 Subject: [PATCH] add MySQL options and corresponding constants --- ext/pdo_mysql/mysql_driver.c | 38 +++++++++++++++++++++++++++++++ ext/pdo_mysql/pdo_mysql.c | 4 ++++ ext/pdo_mysql/php_pdo_mysql_int.h | 4 ++++ 3 files changed, 46 insertions(+) diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index d97e350298..6683e5bba6 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -420,12 +420,50 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ /* handle MySQL options */ if (driver_options) { long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC); + long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC); + char *init_cmd = NULL, *default_file = NULL, *default_group = NULL; + H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 0 TSRMLS_CC); if (mysql_options(H->server, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout)) { pdo_mysql_error(dbh); goto cleanup; } + + if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) { + pdo_mysql_error(dbh); + goto cleanup; + } + + init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL TSRMLS_CC); + if (init_cmd) { + if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) { + efree(init_cmd); + pdo_mysql_error(dbh); + goto cleanup; + } + efree(init_cmd); + } + + default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL TSRMLS_CC); + if (default_file) { + if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) { + efree(default_file); + pdo_mysql_error(dbh); + goto cleanup; + } + efree(default_file); + } + + default_group= pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP, NULL TSRMLS_CC); + if (default_group) { + if (mysql_options(H->server, MYSQL_READ_DEFAULT_GROUP, (const char *)default_group)) { + efree(default_group); + pdo_mysql_error(dbh); + goto cleanup; + } + efree(default_group); + } } dbname = vars[1].optval; diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c index c83fcb42a2..7e1ffaa6d7 100755 --- a/ext/pdo_mysql/pdo_mysql.c +++ b/ext/pdo_mysql/pdo_mysql.c @@ -76,6 +76,10 @@ ZEND_GET_MODULE(pdo_mysql) PHP_MINIT_FUNCTION(pdo_mysql) { REGISTER_PDO_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY); + REGISTER_PDO_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE); + REGISTER_PDO_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND); + REGISTER_PDO_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE); + REGISTER_PDO_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP); return php_pdo_register_driver(&pdo_mysql_driver); } diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index 7879aeb3e5..c54613fa13 100755 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -78,5 +78,9 @@ extern struct pdo_stmt_methods mysql_stmt_methods; enum { PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC, + PDO_MYSQL_ATTR_LOCAL_INFILE, + PDO_MYSQL_ATTR_INIT_COMMAND, + PDO_MYSQL_ATTR_READ_DEFAULT_FILE, + PDO_MYSQL_ATTR_READ_DEFAULT_GROUP, }; #endif -- 2.40.0