You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In PR #142@pmjones suggests a more concise way to handle prepared statement placeholders because the 3.x version feels clunky and verbose. His suggestion uses sequential placeholders and we prefer to use named placeholders for documentation and easier debugging.
So here is a suggestion, which supports a single named placeholder only, but works very well for us because of its conciseness. Usage is like this
$select->where("foo = ", ":FOO", "value")->where("bar IN ", "(:BARS)", [1, 2, 3]);
// AND WHERE foo = :FOO AND WHERE bar IN (:BARS)
Interface looks like this:
/** * * ADD a WHERE condition with a prepared statement placeholder and value to the query. * * @param string $cond the first part of the where condition without the placeholder. e.g. "foo = " or "bar IN" * @param string $placeholder the placeholder as a string. e.g. ":FOO" or "(:BARS)" * @param (string|int|float|array) $value the value to bind to the placeholder. e.g. "abc" or [1, 2, 3] * @return $this */publicfunction where(string$statement, string$placeholder, $bindValue);
Of course there should corresponding versions for orWhere, having .
This is a feature/discussion request. We have extended the ExtendedPDO inhouse to provide the request functionality. I could polish it up, add missing parts and contribute a PR if the project is interested.
The text was updated successfully, but these errors were encountered:
Hi all,
In PR #142 @pmjones suggests a more concise way to handle prepared statement placeholders because the 3.x version feels clunky and verbose. His suggestion uses sequential placeholders and we prefer to use named placeholders for documentation and easier debugging.
So here is a suggestion, which supports a single named placeholder only, but works very well for us because of its conciseness. Usage is like this
Interface looks like this:
Of course there should corresponding versions for orWhere, having .
This is a feature/discussion request. We have extended the ExtendedPDO inhouse to provide the request functionality. I could polish it up, add missing parts and contribute a PR if the project is interested.
The text was updated successfully, but these errors were encountered: