cvs: php-src(PHP_5_1) /ext/pdo pdo_stmt.c /ext/pdo/tests pdo_028.phpt
| From: | Wez Furlong | Date: | Sat, 10 Sep 2005 15:32:05 +0000 |
| Subject: | cvs: php-src(PHP_5_1) /ext/pdo pdo_stmt.c /ext/pdo/tests pdo_028.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-33880@lists.php.net to get a copy of this message | ||
wez Sat Sep 10 11:32:05 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/pdo/tests pdo_028.phpt
Modified files:
/php-src/ext/pdo pdo_stmt.c
Log:
Add PDOStatement::bindValue(), which is similar to bindParam(), except that
it binds the value of the zval at the time it is called, rather than keeping
a reference to the zval and taking the value at execute() time.
http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.118.2.1&r2=1.118.2.2&ty=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.1 php-src/ext/pdo/pdo_stmt.c:1.118.2.2
--- php-src/ext/pdo/pdo_stmt.c:1.118.2.1 Thu Sep 1 10:44:11 2005
+++ php-src/ext/pdo/pdo_stmt.c Sat Sep 10 11:32:04 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_stmt.c,v 1.118.2.1 2005/09/01 14:44:11 gschlossnagle Exp $ */
+/* $Id: pdo_stmt.c,v 1.118.2.2 2005/09/10 15:32:04 wez Exp $ */
/* The PDO Statement Handle Class */
@@ -1393,6 +1393,36 @@
return really_register_bound_param(¶m, stmt, is_param TSRMLS_CC);
} /* }}} */
+/* {{{ proto bool PDOStatement::bindValue(mixed $paramno, mixed $param [, int $type ])
+ bind an input parameter to the value of a PHP variable. $paramno is the 1-based position of the
placeholder in the SQL statement (but can be the parameter name for drivers that support named
placeholders). It should be called prior to execute(). */
+static PHP_METHOD(PDOStatement, bindValue)
+{
+ pdo_stmt_t *stmt = (pdo_stmt_t*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ struct pdo_bound_param_data param = {0};
+
+ param.paramno = -1;
+ param.param_type = PDO_PARAM_STR;
+
+ if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
+ "lz/|l", ¶m.paramno, ¶m.parameter, ¶m.param_type)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|l",
¶m.name,
+ ¶m.namelen, ¶m.parameter, ¶m.param_type)) {
+ RETURN_FALSE;
+ }
+ }
+
+ if (param.paramno > 0) {
+ --param.paramno; /* make it zero-based internally */
+ } else if (!param.name) {
+ pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "Columns/Parameters are
1-based" TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_BOOL(really_register_bound_param(¶m, stmt, TRUE TSRMLS_CC));
+}
+/* }}} */
+
+
/* {{{ proto bool PDOStatement::bindParam(mixed $paramno, mixed &$param [, int $type [, int
$maxlen [, mixed $driverdata]]])
bind a parameter to a PHP variable. $paramno is the 1-based position of the placeholder in the
SQL statement (but can be the parameter name for drivers that support named placeholders). This
isn't supported by all drivers. It should be called prior to execute(). */
static PHP_METHOD(PDOStatement, bindParam)
@@ -1835,6 +1865,7 @@
PHP_ME(PDOStatement, fetch, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDOStatement, bindParam, second_arg_force_ref, ZEND_ACC_PUBLIC)
PHP_ME(PDOStatement, bindColumn, second_arg_force_ref, ZEND_ACC_PUBLIC)
+ PHP_ME(PDOStatement, bindValue, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDOStatement, rowCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDOStatement, fetchColumn, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDOStatement, fetchAll, NULL, ZEND_ACC_PUBLIC)
http://cvs.php.net/co.php/php-src/ext/pdo/tests/pdo_028.phpt?r=1.1&p=1
Index: php-src/ext/pdo/tests/pdo_028.phpt
+++ php-src/ext/pdo/tests/pdo_028.phpt