diff options
author | Wez Furlong <wez@php.net> | 2004-05-19 13:43:07 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-05-19 13:43:07 +0000 |
commit | 6cd27ff8be059d5cc65fe12d356f844e7da03ce5 (patch) | |
tree | b360743791e14dd649c5138db270598f8b8e9fb1 | |
parent | a0b3e870033d54561348d17a783fc7607180f606 (diff) | |
download | php-git-6cd27ff8be059d5cc65fe12d356f844e7da03ce5.tar.gz |
Add $dbh->exec() method.
Rename $dbh->beginWork() to $dbh->beginTransaction().
-rwxr-xr-x | ext/pdo/pdo_dbh.c | 34 | ||||
-rwxr-xr-x | ext/pdo/php_pdo_driver.h | 2 |
2 files changed, 32 insertions, 4 deletions
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 0f0ce5f8cf..01d1c3baf7 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -157,9 +157,9 @@ static PHP_METHOD(PDO, prepare) RETURN_FALSE; } -/* {{{ proto bool PDO::beginWork() +/* {{{ proto bool PDO::beginTransaction() Initiates a transaction */ -static PHP_METHOD(PDO, beginWork) +static PHP_METHOD(PDO, beginTransaction) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); @@ -257,13 +257,41 @@ fail: } /* }}} */ +/* {{{ proto bool PDO::exec(string query) + Execute a query that does not return a row set */ +static PHP_METHOD(PDO, exec) +{ + pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); + pdo_stmt_t *stmt; + char *statement; + long statement_len; + int rows; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &statement, &statement_len)) { + RETURN_FALSE; + } + + if (!statement_len) { + RETURN_FALSE; + } + + rows = dbh->methods->doer(dbh, statement, statement_len TSRMLS_CC); + + if (rows >= 0) { + RETURN_LONG(rows); + } + + RETURN_FALSE; +} +/* }}} */ function_entry pdo_dbh_functions[] = { PHP_ME(PDO, prepare, NULL, ZEND_ACC_PUBLIC) - PHP_ME(PDO, beginWork, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PDO, beginTransaction,NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, commit, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, rollBack, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, setAttribute, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PDO, exec, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index a7de8d7c82..59a445b46e 100755 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -99,7 +99,7 @@ typedef int (*pdo_dbh_close_func)(pdo_dbh_t *dbh TSRMLS_DC); typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, long options, zval *driver_options TSRMLS_DC); /* execute a statement (that does not return a result set) */ -typedef int (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql TSRMLS_DC); +typedef int (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, int sql_len TSRMLS_DC); /* quote a string */ typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen TSRMLS_DC); |