Edit report at http://bugs.php.net/bug.php?id=40891&edit=1

 ID:                 40891
 Comment by:         bastard dot internets at gmail dot com
 Reported by:        john dot navratil at sbcglobal dot net
 Summary:            mysqli_stmt_bind_param should accept array of
                     parameters to bind
 Status:             Open
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   Fedora Core 5
 PHP Version:        5.2.1
 Block user comment: N
 Private report:     N

 New Comment:

Old request, but I'd like to see this feature added.  Personally, I'd
like to see the ability to pass a user defined object as well.


Previous Comments:
------------------------------------------------------------------------
[2007-03-22 13:24:04] john dot navratil at sbcglobal dot net

Description:
------------
I've read bug #31096 and this is a variant of the same bug, but I
beseech you to reconsider.



The C API to mysql defines my_bool mysql_stmt_bind_param(MYSQL_STMT
*stmt, MYSQL_BIND *bind) to accept an array of parameters to bind to a
prepared statement.  PHP 5.2.1 does not and requires the number of
parameters to match both the number of characters in the type string
(essentially an array of types) and the number of parameters in the
prepared statement.  This works well for static statements but makes
dynamic statements impossible to prepare unless one resorts to something
like:



$arr = <array-of-values-to-be-bound>

array_unshift($arr, $typeString);

call_user_func_array(array(& $mysqli, "stmt_bind_param"), $arr);

array_shift($arr);



One can argue that this is sufficient (a point which I will concede),
but the beauty of PHP is not in its sufficiency (machine code is
sufficient, ultimately) but in its expressivity.  The foregoing is not
very expressive, is tightly bound to the mysqli_stmt_bind_result
signature, and does not mirror the underlying API (which is another PHP
strong point).



Would you please consider a variant which accepts two arguments with the
second being an array of values to bind to the prepared statement?



Thanks!



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=40891&edit=1

Reply via email to