# [RFC] mysqli bind in execute

- Thread: https://externals.io/message/113149
- Original archive: https://news-web.php.net/php.internals/113149
- Started by Kamil Tekiela on 2021-02-11T19:43:16+00:00
- Messages: 5
- RFC: Mysqli bind in execute (Implemented (PHP 8.1)) — https://externals.io/rfc/mysqli_bind_in_execute.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #113149 — Kamil Tekiela — 2021-02-11T19:43:16+00:00

URL: https://externals.io/message/113149#113149

Hi internals,

I am proposing the next change to improve mysqli extension. This RFC's goal
is to add a new optional parameter to mysqli_stmt:execute() that will take
an array of parameters.

The RFC is located at https://wiki.php.net/rfc/mysqli_bind_in_execute

I'd be happy to hear your comments.

Kind Regards,
Kamil Tekiela

---

## #113150 — Craig Francis — 2021-02-12T00:36:10+00:00

URL: https://externals.io/message/113149#113150 · In reply to: #113149

> https://wiki.php.net/rfc/mysqli_bind_in_execute
>
> I'd be happy to hear your comments.




Please let this pass.

The current approach is absolutely horrible and causes so many developers
using mysqli to do things incorrectly (like trying to use escaping, which
is so easy to get make mistakes with).

Craig





> Hi internals,
>
> I am proposing the next change to improve mysqli extension. This RFC's goal
> is to add a new optional parameter to mysqli_stmt:execute() that will take
> an array of parameters.
>
> The RFC is located at https://wiki.php.net/rfc/mysqli_bind_in_execute
>
> I'd be happy to hear your comments.
>
> Kind Regards,
> Kamil Tekiela

---

## #113254 — Claude Pache — 2021-02-25T08:35:56+00:00

URL: https://externals.io/message/113149#113254 · In reply to: #113149

> Le 11 févr. 2021 à 20:43, Kamil Tekiela <tekiela246@gmail.com> a écrit :
> 
> Hi internals,
> 
> I am proposing the next change to improve mysqli extension. This RFC's goal
> is to add a new optional parameter to mysqli_stmt:execute() that will take
> an array of parameters.
> 
> The RFC is located at https://wiki.php.net/rfc/mysqli_bind_in_execute
> 
> I'd be happy to hear your comments.
> 
> Kind Regards,
> Kamil Tekiela

Hi,

In the paragraph “Difference between PDO and mysqli”, you propose:

“Array keys are completely ignored. mysqli doesn't have emulated prepares nor does it have named parameters.”

Instead of ignoring the keys, I think it is better to throw a TypeError when the provided array is not a “list” in the sense of `array_is_list()` introduced [in a recent RFC] (https://wiki.php.net/rfc/is_list). The reasons are:

* provide the user with useful feedback when they are attempting to do something dubious and/or their intent is ambiguous;
* be forward compatible with possible future addition of named parameters;
* reduce the difference with PDO for input that are accepted in both mysqli and PDO.

—Claude

---

## #113315 — Kamil Tekiela — 2021-02-27T18:53:55+00:00

URL: https://externals.io/message/113149#113315 · In reply to: #113254

>
> Hi,
>
> In the paragraph “Difference between PDO and mysqli”, you propose:
>
> “Array keys are completely ignored. mysqli doesn't have emulated prepares
> nor does it have named parameters.”
>
> Instead of ignoring the keys, I think it is better to throw a TypeError
> when the provided array is not a “list” in the sense of `array_is_list()`
> introduced [in a recent RFC] (https://wiki.php.net/rfc/is_list). The
> reasons are:
>
> * provide the user with useful feedback when they are attempting to do
> something dubious and/or their intent is ambiguous;
> * be forward compatible with possible future addition of named parameters;
> * reduce the difference with PDO for input that are accepted in both
> mysqli and PDO.
>
> —Claude
>
>
 Hi Claude,

Thanks for the feedback. I thought about it and I have to say I honestly do
not know which way would be better. I haven't received any other comments
so far. What you are proposing makes sense, but I don't know how to
implement this. I am not so experienced with PHP internals so I would
require some help to add such an error.

The only other comments I have seen so far are from Reddit
https://www.reddit.com/r/PHP/comments/llntv5/php_rfc_mysqli_bind_in_execute/

I could add another voting option for people to decide whether they want
the keys to be ignored or if they want an error. I appreciate it if anyone
has any other comments about this proposal too.

Kind Regards,
Kamil

---

## #113332 — Kamil Tekiela — 2021-02-28T18:40:35+00:00

URL: https://externals.io/message/113149#113332 · In reply to: #113315

Hi All,

I have changed the RFC based on the last suggestion. If the argument is not
a list array then a ValueError will be thrown.
If anyone is opposed to this change and instead would prefer the previous
behaviour please explain your reasoning.

Regards,
Kamil
