I just tried to write a conditional query and found the documentation's use if (AND, OR, etc.) really annoying. Patch to provide full list of supported operators.

Comments

agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new803 bytes

And the patch file.

dries’s picture

Status: Needs review » Fixed

Nice little improvement. Committed to CVS HEAD.

Crell’s picture

Status: Fixed » Needs work

This patch is wrong. db_condition wraps the constructor for DatabaseCondition. The conjunction is for joining two or more conditional clauses. IN, BETWEEN, NOT NULL, and the rest are conditional comparators like = and >, not conjunctions. If you pass NOT NULL to a db_condition(), you'll get the following syntax error: WHERE foo = bar NOT NULL baz = bob

The ->condition() method takes conditional comparators. That is not the same as db_condition(), which is a factory for the DatabaseCondition class. Really, you should never use db_condition() directly. Use db_or(), db_and(), and db_xor(). db_condition() is only there in case there's another conjunction that we forgot, which I don't think we did.

This needs to be rolled back.

agentrickard’s picture

Category: feature » task

You still need to document the @param as $conjunction, though.

@Crell -- any idea where we can put the operator list in the API docs?

agentrickard’s picture

Status: Needs work » Needs review
StatusFileSize
new1.21 KB

Revised patch which reverts the error and provides accurate docs.

Crell’s picture

Status: Needs review » Needs work

The first hunk in #5 is incorrect, since "AND" is not an operator. The operators are = (the default), <, >, <=, >=, IN, NOT IN, LIKE, NOT LIKE, BETWEEN, and anything else SQL supports there (except for IS NULL and IS NOT NULL, which have their own utility methods). I don't think an exhaustive list there is even wise, since it's just replicating a large chunk of core SQL documentation.

I'd rather beef up the description there to define what sorts of things go there, with a few examples, rather than try to make an exhaustive list and miss one.

Crell’s picture

Status: Needs work » Needs review
StatusFileSize
new908 bytes

Let's try this.

agentrickard’s picture

StatusFileSize
new897 bytes

Oops. Typo. (funciton). Maybe this?

Crell’s picture

Status: Needs review » Reviewed & tested by the community

D'Oh! Yes.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD.

Status: Fixed » Closed (fixed)
Issue tags: -Documentation

Automatically closed -- issue fixed for 2 weeks with no activity.