Skip to content
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

Track progress on native prepared statements #44

Open
iandunn opened this issue Apr 14, 2021 · 2 comments
Open

Track progress on native prepared statements #44

iandunn opened this issue Apr 14, 2021 · 2 comments

Comments

@iandunn
Copy link
Member

iandunn commented Apr 14, 2021

A lot of the complexity around escaping queries would be simplified if Core supported native MySQL prepared statements.

It'll be worth following that ticket in the future, and maybe even coordinating w/ the Core team to push it forward.

@tellyworth
Copy link
Collaborator

What problems would native prepared statements solve? Would it reduce complexity for plugin developers and other users of the wpdb API?

The most complex queries at the moment are ones that involve lists (WHERE foo IN( ... )) and complex WHERE clauses pieced together from multiple conditional pieces. What would they look like using native prepares?

@iandunn
Copy link
Member Author

iandunn commented Apr 19, 2021

complex WHERE clauses pieced together from multiple conditional pieces

That's mostly what I was thinking about, but also the difficultly escaping table/column names. In general, the problem is the ambiguity between what's a table/column name, what's syntax, and what's a value.

Prepared statements should make the values explicit, and WPDB could wrap table/column names in backticks for additional guardrails.

It could make the recommendations much easier if we could just say, "use this new API that fixes the problems and complexity of the old one".

I could be misreading it, though, and the implementation could impact the details. What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants