ahri / ahriphplibs

My PHP Libraries
http://ahri.net
GNU Affero General Public License v3.0
3 stars 0 forks source link

Query chaining #21

Open ahri opened 14 years ago

ahri commented 14 years ago

Re-implement old idea (from Orm) of "chaining".

Should be able to specify "chain" of classes and relationships to be able to efficiently pull out a set of objects.

e.g. A -> (Rel1) -> B -> (Rel2) -> C

ahri commented 14 years ago

Can maybe retro-fit this into the relationship loader so that it doesn't need to perform 2 queries as is currently the case.

ahri commented 14 years ago

This is basically DSL territory, and should be considered thoroughly. Will we be able to specify WHERE clauses in the chains, too?

Suggested syntax: A [foo > 2] -> (Rel1) -> B -> (Rel2 [a = 'bar']) -> C

ahri commented 14 years ago

Multiline might be nicer for longer ones?

A [foo > 2] ->
(Rel1) ->
B ->
(Rel2 [a = 'bar']) ->
C

Or perhaps a newline implies a -> ?

A [foo > 2]
(Rel1)
B
(Rel2 [a = 'bar'])
C
ahri commented 14 years ago

Should specify with an asterisk after the name if you want an object back.

A* [foo > 2]
(Rel1)
B
(Rel2 [a = 'foo', b = 'bar'])
C*