Add *whereBoundValue functions to Where trait and interface - #165
Conversation
|
Just a note what we did inhouse to extend the functionality - we extended the QueryFactory#newSelect to return a Select instance extended by a trait which contains the necessary functionality. The problem with that implementation is that extended QueryFactory hardwires the database dialect. |
|
Hi @dc2xl, apologies this sat so long without a reply. Picking this up while going through the open queue for 6.x. The need behind #164 is real, but I think it's since been covered by the existing $select->cols(['*'])->from('t')
->where('c2 IN (:c2)', ['c2' => ['foo', 'bar']])
->where('c3 = :c3', ['c3' => 'foo']);SELECT
*
FROM
`t`
WHERE
c2 IN (:__1__, :__2__)
AND c3 = :c3$select->getBindValues();
// ['__1__' => 'foo', '__2__' => 'bar', 'c3' => 'foo']That's one call per condition with named placeholders, which was the conciseness #164 was after, and the array case is expanded into individual binds rather than left as a single array value. Scalar placeholders keep the name you wrote; array ones get rewritten to Worth noting because it affects this PR directly: Given that, plus the things you already called out (no Thanks for taking the time to write it up, and again, sorry for the delay. |
@harikt just note where the PR/approach offers some value: It provides name consistency at definition time (when you call the |
|
cool. May be your fork is private I believe. I will look more closely into this, what we can do regarding type check you mentioned. Thanks again for taking your time. |
This is a working minimal implementation for #164 to get coding feedback.
Implementation is directly in the WhereTrait with a separate function name ("whereBoundValue") in order to keep the where function interfaces clean.
As alternative to the direct implementation I considered having a separate trait; so the framework user could easily decide if the functionality is wanted by composing traits. But this seems infeasible considering how the factory/implementation lookup works.
What is mainly missing is *having support.