|
|
||||||||||||||||||||||||||
|
|
Design Your Queries Like A BossAs I often repeat the same advice on questions like "What to put in Propel Queries?", or "How to name things?", I decided to share it here. When you design a software, it's important to use appropriate names for each part, each class, and even each method. In Propel, the ActiveQuery API is probably the most powerful part of your Model, that's why you should take care of it. First, you should use objects, and forget SQL. If you try to write Propel Queries like SQL queries, you are on the wrong path. A few months ago, someone complained about Propel queries on Twitter because he couldn't write a query. Here is my advice, and his answer: that's because you're too close to a SQL mind, try to think with an object oriented mind :) — William DURAND (@couac) October 9, 2011 @couac m.. yes, thinking about "traversing across object relations" instead of "let's retrieve data" may help when doing complex queries.thx — Nacho Martin (@nacmartin) October 9, 2011 That's exactly the point! Propel is an ORM you probably use in an OO framework, so why do you want to use SQL, or another query language? Once you are aware of that, you'll be able to write queries offering the same advantages as objects: encapsulation, reusability, expressivity. The next step is to understand filters. Filters are reusable methods which add conditions to a query. In a Propel Query, you have generated filters like filterById(), filterByUser(), etc. which allow you to write nice queries: 1 2 3 4 5 6 7 8
my
|
theming
|
essentials
|
rohrscheib
|
next
|
look
|
experiences
|
group
|
digest
|
social
|
ext
|
gwt
|
coming
|
collaboration
|
appearance
|
device
|
part
|
magento
|
go
|
great
|
edge
|
new
|
store
|
chua
|
minutes
|
help
|
build
|
multi
|
propel
|
binding
|
client
|
much
|
becomes
|
announcing
|
toku
|
multiclient
|
db
|
eriksson
|
identify
|
easier
|