Skip to content

Support SQLite3 @name notation #3636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 24, 2018

Besides the common :param notation to designate named parameters in
prepared statements, SQLite3 also supports @param and $param.
While the latter is mostly to support the Tcl programming language, and
would be confusing for PHP's sqlite3 binding due to the similarity with
string interpolation, the former is common under .NET and raises no
such issue. Therefore we add support for it.

This patch has been developed in cooperation with @bohwaz.

Besides the common `:param` notation to designate named parameters in
prepared statements, SQLite3 also supports `@param` and `$param`.
While the latter is mostly to support the Tcl programming language, and
would be confusing for PHP's sqlite3 binding due to the similarity with
string interpolation, the former is common under .NET and raises no
such issue.  Therefore we add support for it.

This patch has been developed in cooperation with @bohwaz.
@petk petk added the Feature label Oct 24, 2018
@cmb69
Copy link
Member Author

cmb69 commented Nov 5, 2018

If there are no objections, I'll merge this on the next weekend.

@nikic
Copy link
Member

nikic commented Nov 5, 2018

I don't object, but I also don't really see the point here. It seems weird to introduce a sqlite-specific syntax, while we already have one that is universally supported (through pdo if nothing else).

@cmb69
Copy link
Member Author

cmb69 commented Nov 5, 2018

Well, the syntax is supported by SQLite anyway. It is, however, not possible to bind to a parameter in @param notation. This appears to be unnecessarily confusing, particularly for people with a .NET background.

@bohwaz
Copy link
Contributor

bohwaz commented Nov 7, 2018

My point was that this syntax is allowed by SQLite (and so you expect it to work), but the PHP implementation broke it, trying to add "smart" behaviour (in prefixing a parameter name with a double colon when it doesn't have one). So this patch is just a bugfix actually :)

@nikic
Copy link
Member

nikic commented Nov 7, 2018

Fair enough, please feel free to go ahead.

As an unrelated point, the following zend_string_init can be replaced by a zend_string_copy. Duplicating the string does not appear to be necessary here.

@cmb69
Copy link
Member Author

cmb69 commented Nov 7, 2018

As an unrelated point, the following zend_string_init can be replaced by a zend_string_copy. Duplicating the string does not appear to be necessary here.

Good catch, thanks! Fixed via b7b3a65.

php-pulls pushed a commit that referenced this pull request Nov 7, 2018
@php-pulls
Copy link

Comment on behalf of cmb at php.net:

Applied as 86c6b3b.

@php-pulls php-pulls closed this Nov 11, 2018
@cmb69 cmb69 deleted the sqlite3-allow-at-params branch November 11, 2018 13:58
@cmb69
Copy link
Member Author

cmb69 commented Nov 11, 2018

salathe pushed a commit to salathe/phpdoc-en that referenced this pull request Nov 11, 2018
Cf. <php/php-src#3636>.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345971 c90b9560-bf6c-de11-be94-00142212c4b1
svn2github pushed a commit to svn2github/phpdoc_en that referenced this pull request Nov 14, 2018
Cf. <php/php-src#3636>.

git-svn-id: http://svn.php.net/repository/phpdoc/en@345971 c90b9560-bf6c-de11-be94-00142212c4b1
heiglandreas pushed a commit to phpdoctest/en that referenced this pull request Feb 4, 2020
Cf. <php/php-src#3636>.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345971 c90b9560-bf6c-de11-be94-00142212c4b1
salathe pushed a commit to salathe/phpdoc-en that referenced this pull request Sep 3, 2020
Cf. <php/php-src#3636>.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345971 c90b9560-bf6c-de11-be94-00142212c4b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants