Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
New DQL Criteria API
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 32 of 32 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Joaquin Bravo Contreras  
View profile   Translate to Translated (View Original)
 More options 29 May, 16:38
From: Joaquin Bravo Contreras <jackbr...@gmail.com>
Date: Fri, 29 May 2009 10:38:22 -0500
Local: Fri 29 May 2009 16:38
Subject: Re: [doctrine-dev] Re: New DQL Criteria API

hahaha, ok ok.

I must agree that those convinience methods only clutter the API.
I also like the example roman gave: http://pastie.org/493835

Which API is easier to implement? or more straight forward? I guess that
should be also something to consider.

- Joaquín


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Pereira  
View profile   Translate to Translated (View Original)
 More options 29 May, 22:23
From: Jorge Pereira <jpereira...@gmail.com>
Date: Fri, 29 May 2009 14:23:30 -0700 (PDT)
Local: Fri 29 May 2009 22:23
Subject: Re: New DQL Criteria API

>> I think it's acceptable to use var-arg for Expr::or, but there is no such thing as "OR between 3 variables". OR is a binary operator, and the order in which conditions are evaluated is significant.

OR is a binary operator, but in "pure" functions (ones that have no
sideffects) the evaluation order is irrelevant. And when you type in
an SQL query:
    A or B or C or D
You certainly aren't thinking about the evaluation order, and if you
were, pointless, because a good query optimizer will likely choose
which one to evaluate first based on function evaluation statistics
and "type simplicity".

In any case, imho it's totally wrong to force programmers to write or
(A,or(B,or(C,D))). :)

As for you "who will be responsible" question, the programmer. That
will simply turn out to be an invalid query.

On 29 May, 15:41, Eugene Janusov <esy...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bernhard Schussek  
View profile   Translate to Translated (View Original)
 More options 30 May, 11:56
From: Bernhard Schussek <bschus...@gmail.com>
Date: Sat, 30 May 2009 12:56:32 +0200
Local: Sat 30 May 2009 11:56
Subject: Re: [doctrine-dev] Re: New DQL Criteria API
Hi all,

Although I think that Jorge's approach looks very nice at the first
glance, I don't think it is the way to go. As far as I have
understood, the core team is trying to build an alternative,
_object-oriented_ approach to writing conditional queries.

All other solutions except for #1 have a very nice interface, but you
can only use this interface if you are building the query in one place
(i.e. a method, function etc.). You cannot at all (or not very
intuitively) build different parts of the query in different parts of
your application, which seems to be what this alternative approach is
all about.

http://pastie.org/494869

The object oriented approach allows you to construct your query in a
very modular fashion. The only big drawback with my above sample is
that you have to mix the "normal" way of writing a query (aka
->where('m.attr1 = ?', 1)) with the object oriented way within the
same method. A nicer way of writing this is

http://pastie.org/494870

How would such this example be written with Jorge's approach?

Bernhard


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Pereira  
View profile   Translate to Translated (View Original)
 More options 30 May, 16:41
From: Jorge Pereira <jpereira...@gmail.com>
Date: Sat, 30 May 2009 08:41:04 -0700 (PDT)
Local: Sat 30 May 2009 16:41
Subject: Re: New DQL Criteria API
Well, as someone with both a functional and imperative programming
background, I must say that it looks very natural. :) It allows you to
build complex queries without interrupting the chain. I could point a
number of very successful libraries that take this approach inspired
by functional Monads, such as jQuery (which even has a ->foreach).

Still, whether you include control elements or not is a different
discussion. The relevant aspect here is that using #1 you drop the
natural order of building a query and force the programmer to nest
operations that in an SQL query are written in a linear manner. Case
in point:
(A or B or C or D)  vs or(A, or(B, or(C,D)))

This also makes it very hard adding pieces of a query inside an "or".
I'm not sure how we could defend #1 given this, and it seems somewhat
obvious that an approach based on #4 is far easier to read and write.
If after making that decision you decide to include or not if/elseif
controls, that is another issue, but it's a very natural extension of
beginBlock/endBlock, and even if you don't like it you'll certainly
agree that it's very easy to read and write. In any case, you can
still write things by resorting only to php language constructs.

Regards,

On 29 May, 16:32, Eugene Janusov <esy...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Pereira  
View profile   Translate to Translated (View Original)
 More options 30 May, 16:57
From: Jorge Pereira <jpereira...@gmail.com>
Date: Sat, 30 May 2009 08:57:46 -0700 (PDT)
Local: Sat 30 May 2009 16:57
Subject: Re: New DQL Criteria API
Great example, that is actually the point to focus in.

I would say that an alternative way to write http://pastie.org/494870
could be http://pastebin.com/d282b4be8

But in any case, I'll be glad with any suggestion that doesn't force
you to nest or/and. As a middleground between both approaches, I'd say
maybe consider the 2nd option here http://pastebin.com/d282b4be8,
which is basically
$q->orWhere( array(
       Expr::eq('attr1', $value1),
       Expr::or(),
       Expr::eq('attr2', $value2)
      ) );

Regards,

On 30 May, 11:56, Bernhard Schussek <bschus...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ren  
View profile   Translate to Translated (View Original)
 More options 19 June, 17:50
From: Ren <Jared.Willi...@ntlworld.com>
Date: Fri, 19 Jun 2009 09:50:41 -0700 (PDT)
Local: Fri 19 June 2009 17:50
Subject: Re: New DQL Criteria API

> The issue imho is that you loose all sense of order with that,
> compared to a standard query. If PHP allowed you to define functions
> as operators (eg, such as in Prolog or Lisp) it wouldn't be much of a
> problem.

pecl/operator does operator overloading...

->where($userTable->name == 'Ren' && $userTable->isactive == 1 &&
$userTable->postCount > 100);

is possible.
But given hardly no one uses the extension (based on the fact tinkered
with code to do the above over 3 years ago), and no sign of it being
included in default install, the idea is going nowhere.

Jared


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Jorgensen  
View profile   Translate to Translated (View Original)
 More options 23 June, 09:20
From: Adam Jorgensen <adam.jorgensen...@googlemail.com>
Date: Tue, 23 Jun 2009 01:20:41 -0700 (PDT)
Local: Tues 23 June 2009 09:20
Subject: Re: New DQL Criteria API
Hey all, thought I'd comment on this.

The possibilities provided via the pastebin link are interesting and
bear, as far as I can see, a great deal of resemblance to the Criteria
API provided by Propel.
Propel's Criteria API is, insofar as I have worked with it, okay but
not great. Although it's flexible it's not very elegant.

At my workplace we use a web framework called QCubed (A fork of QCodo)
which provides, among other things, an ORM layer. The ORM layer
provided by QCubed is nowhere near as powerful or as flexible as that
provided by Doctrine, but the Query Building system (QQuery) is
actually pretty damn nice, even though it does lack certain features
(Slated for addition, but the QCubed community is moving slowly in
this regard)

Basically, QCubed Queries take the following form...

SomeTable::QueryArray(
  QQ::AndCondition(
    QQ::Equal(QQN::SomeTable->Deleted, false),
    QQ::GreaterThan(QQN::SomeTable->Id, 5),
    QQ::IsNull(QQN::SomeTable->RelatedTable->Id)),
  QQ::Clause(
    QQ::OrderBy(QQN::SomeTable->SomeColumn));

That's a pretty basic example. More examples can be found at:
http://examples.qcu.be/

The code generation system for the QCubed framework does two things
with regards to ORM codegen:

1: It builds Row entity classes for each Table.
2: It builds Query Node classes for each Table, as well as Query Node
classes for the various relationships between the Tables.

As it is, QQuery is powerful, but lacks a lot of flexibility.
Nevertheless, I think it could provide something to look at.

As I see it the pros and cons of QQuery are as follows:

Pros:
Readable, Logical Query syntax
Query syntax essentially allows for OO-based SQL queries
QQNodes document database traversal nicely (I actually contributed
code to QCubed in this regard that generates PHPDoc comments for
QQNodes)

Cons:
No WHERE handling. QQuery does not allow you to select custom columns
and late-bind entity data as Doctrine does
No custom JOIN support. You may only join along direct relationships.
Multiple joins and custom joins are not supported.
Limited support for certain features such as nested selects custom
columns (As generated by usage of SQL functions such as count(), etc)
Somewhat verbose
Not directly chainable (Allow Conditions and Clauses can be generated
Ad-Hoc and stored in arrays for use with things like QQ::AndCondition
() and QQ::Clause()

As I see it, a query building system that draws on the strengths of
QQuery while also improving upon its failings would be a good place to
look.

That said, I also realise that there are flaws with the QQuery model
that could make certain things very hard (Handling of multiple and
custom joins for one...)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google