]> granicus.if.org Git - php/commitdiff
Added support for setting timeout value.
authorIlia Alshanetsky <iliaa@php.net>
Wed, 19 May 2004 20:34:57 +0000 (20:34 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 19 May 2004 20:34:57 +0000 (20:34 +0000)
ext/pdo_mysql/mysql_driver.c

index 3f64a8326f2cebe73153d4fc2fc5fbd28d37401f..bc618f452948a8cd6fa4d97bb3b61a8e91ef91d3 100755 (executable)
@@ -143,6 +143,17 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
        /* handle for the server */
        H->server = mysql_init(NULL);
        dbh->driver_data = H;
+
+       /* handle MySQL options */
+       if (driver_options) {
+               long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
+
+               if (mysql_options(H->server, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout)) {
+                       pdo_mysql_error(H);
+                       goto cleanup;
+               }
+       }
+
        if(vars[2].optval && strcmp("localhost", vars[2].optval)) {
                host = vars[2].optval;
                port = atoi(vars[3].optval);