ZF-2227: Allow where method to accept multiple placeholders

Description

Allow where() to accept multiple placeholders.

This would allow users to build clauses which are not possible with the actual implementation.


->where("((price > ? or price <= ?) and name like ?) or price in (?)", 1, 5, 'user%', 20, 30, 40, 50);
// where ((price > 1 or price <= 5) and name like 'user%') or price in (20, 30, 40, 50)

Multiple placeholders are quite easy to implement. Just 3 rules which are relevant: * If the amount of placeholders and values are equal replace each placeholder with the value * If there are more placeholders than values some placeholders would stay within the query * If there are more values than placeholders the not filled values would be compressed with ", value"

Usecase:


->where("(price > ? and price < ?) or name like (?)", 2, 5, 'demo%');
// where (price > 2 and price < 5) or name like ('demo%')

Usecase:


->where("(price > ? and price < ?) or name like (?)", 2, 5);
// where (price > 2 and price < 5) or name like (?)

There are two possibilities... Eigther allow not filled placeholders, or throw an exception if placeholders are not filled.

Usecase:


->where("(price > ? and price < ?) or price IN (?)", 2, 5, 20, 30, 40, 50);
// where (price > 2 and price < 5) or price like (20, 30, 40, 50)

This way the old undocumented behaviour would also be accepted... Usecase:


->where("price IN (?)", 20, 30, 40, 50);
// where price like (20, 30, 40, 50)

Comments

Integrated with SVN7576. Cored with Release 1.5

Documentation should be updated to reflect this change. Currently it says (Section 10.4 Example 10.54): {quote} This method accepts only one parameter. If you have an expression into which you need to substitute multiple variables, you must format the string manually, interpolating variables and performing quoting yourself. {quote}

Documentation change necessary

Thomas, are you planning to update the docs? If not, please reassign to Ralph.

Reassigned to component lead.

AFAIK, this was never actually implemented in trunk or has been reverted between 1.5 and now as the where method does not work as described by OP. Regardless, this is a duplicate of ZF-2142 so closing as duplicate.