PDO_API int php_pdo_register_driver(pdo_driver_t *driver)
{
- if (driver->api_version != PDO_DRIVER_API)
+ if (driver->api_version != PDO_DRIVER_API) {
+ zend_error(E_ERROR, "failed api version check");
return FAILURE;
-
+ }
if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
zend_error(E_ERROR, "You MUST load PDO before loading any PDO drivers");
return FAILURE; /* NOTREACHED */
}
/* }}} */
-/* {{{ proto bool PDO::exec(string query)
- Execute a query that does not return a row set */
+/* {{{ proto long PDO::exec(string query)
+ Execute a query that does not return a row set, returning the number of affected rows */
static PHP_METHOD(PDO, exec)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
char *statement;
long statement_len;
+ long ret;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &statement, &statement_len)) {
RETURN_FALSE;
if (!statement_len) {
RETURN_FALSE;
}
-
- RETURN_BOOL(dbh->methods->doer(dbh, statement, statement_len TSRMLS_CC));
-}
-/* }}} */
-
-/* {{{ proto int PDO::affectedRows()
- Returns the number of rows that we affected by the last call to PDO::exec(). Not always meaningful. */
-static PHP_METHOD(PDO, affectedRows)
-{
- pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
-
- if (ZEND_NUM_ARGS()) {
+ ret = dbh->methods->doer(dbh, statement, statement_len TSRMLS_CC);
+ if(ret == -1) {
RETURN_FALSE;
}
-
- if (!dbh->methods->affected) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver affected rows retrieval.");
- } else {
- RETURN_LONG(dbh->methods->affected(dbh TSRMLS_CC));
+ else {
+ RETURN_LONG(ret);
}
}
/* }}} */
+
/* {{{ proto int PDO::lastInsertId()
Returns the number id of rows that we affected by the last call to PDO::exec(). Not always meaningful. */
static PHP_METHOD(PDO, lastInsertId)
PHP_ME(PDO, rollBack, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, setAttribute, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, exec, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(PDO, affectedRows, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, lastInsertId, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
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, long sql_len TSRMLS_DC);
+typedef long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, long 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);
/* setting and getting of attributes */
typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
-/* return affected rows */
-typedef long (*pdo_dbh_affected_func)(pdo_dbh_t *dbh TSRMLS_DC);
-
/* return last insert id */
typedef long (*pdo_dbh_last_id_func)(pdo_dbh_t *dbh TSRMLS_DC);
pdo_dbh_txn_func commit;
pdo_dbh_txn_func rollback;
pdo_dbh_set_attr_func set_attribute;
- pdo_dbh_affected_func affected;
pdo_dbh_last_id_func last_id;
};