db query where() method argument order

252 views
Skip to first unread message

Adam Stephen Docherty

unread,
Aug 9, 2012, 3:46:14 PM8/9/12
to joomla-...@googlegroups.com
Would it not seem more readable to have the second argument as it currently stands:
$query->where( 'field.a = 1', 'OR' ); $query->where( 'field.b = 2' );

Changed to be the first argument:
$query->where( 'field.a = 1' ); $query->where( 'OR', 'field.b = 2' );

Also have it a *requirement to declare the operator in the first argument of a where() method following another. This seems to be more logical to me. Also when the sql in the first argument is long it can be easy to miss the addition of the operator override...

Adam Stephen Docherty

unread,
Aug 9, 2012, 3:48:19 PM8/9/12
to joomla-...@googlegroups.com
oh and I do realise that this kind of change would "break the world" so it is probably not feasible at this time...

elin

unread,
Aug 9, 2012, 9:10:03 PM8/9/12
to joomla-...@googlegroups.com

$query->where(array ('field.a = 1' ,'field.b = 2'), 'OR' );
is also an alternative.

No I don't think it's particularly more logical to have it first especially since it is optional both because sometimes you have only one condition and because sometimes you are using AND and just want to use the default. If you put it first you would have to deal with it all the time.

Elin

Sam Moffatt

unread,
Aug 11, 2012, 10:13:54 PM8/11/12
to joomla-...@googlegroups.com
I agree that having the operator there all of the time doesn't make
sense in addition to being something not particularly backwards
compatible friendly. In the vast majority of cases an AND statement as
a default makes sense. I do like where this is headed however as it
allows the same level of simplicity with have with a reasonably quick
way of overriding the glue on a per clause basis.

Cheers,

Sam Moffatt
http://pasamio.id.au
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! CMS Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-cms/-/Q7FwJ4ivRg4J.
>
> To post to this group, send an email to joomla-...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-cm...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

elin

unread,
Aug 11, 2012, 11:30:16 PM8/11/12
to joomla-...@googlegroups.com
We had quite a detailed discussion of WHERE glue in the git hub tracker although nothing ever really came of it.
 
Elin
Reply all
Reply to author
Forward
0 new messages