| mysql operator hierarchy and propel [message #21955] |
Mon, 19 February 2007 10:34  |
searaig Messages: 43 Registered: December 2006 Location: vancouver |
Member |
|
|
quick mysql question.
in one of the more recent mysql release they changed the precedence of "," (comma) operator to be lower than `JOIN`
so,
SELECT *
FROM a, b, c
LEFT JOIN d ON c.id = d.id
WHERE a.id = b.id
AND b.id = c.id
This was a small change but why not just rewrite BEDMAS while you're at it? or perhaps this is a standard that came late.
as a result i started rewriting my queries like this,
SELECT *
FROM a
INNER JOIN b ON a.id = b.id
INNER JOIN c ON b.id = c.id
LEFT JOIN d ON c.id = d.id
will propel or creole look after this kind of "feature" for me when building the model?
if not how would i be able to get data from the database with this type of query using Criteria()?
may seem like a small point but i see it as quite significant.
|
|
|
|
|
| Re: mysql operator hierarchy and propel [message #22016 is a reply to message #21955 ] |
Mon, 19 February 2007 23:00   |
halfer Messages: 9514 Registered: January 2006 Location: West Midlands, UK |
Faithful Member |
|
|
When I got started, I cheated... I didn't use Criteria at all and just used custom SQL. As I learnt more about Criteria and Criterions, I went back and refactored after I gained the satisfaction of a working application. You might want to do the same - you can always tweak stuff later after your learning curve levels off.
http://www.symfony-project.com/snippets/snippet/11
Alternatively don't forget that Doctrine is available too, and is (so I hear) in a very usable beta state.
Remember Palestine
|
|
|
|
| Re: mysql operator hierarchy and propel [message #22057 is a reply to message #21955 ] |
Tue, 20 February 2007 12:50   |
halfer Messages: 9514 Registered: January 2006 Location: West Midlands, UK |
Faithful Member |
|
|
|
Also another thing I like doing - for commonly used queries I write a view, and then create the view in my schema with a read-only tag. It's a reasonably clean solution and saves a lot of messing around with Propel.
[Updated on: Tue, 20 February 2007 12:50] Remember Palestine
|
|
|
|
| Re: mysql operator hierarchy and propel [message #26553 is a reply to message #21955 ] |
Wed, 02 May 2007 13:16   |
halfer Messages: 9514 Registered: January 2006 Location: West Midlands, UK |
Faithful Member |
|
|
OK, let's say you have a commonly used select statement involving three or more tables, perhaps with some left joins, or some features (such as subselects) that are tricky to arrange in Propel. My solution is to create a view in my database that performs the select that I require, and then I add this in as a "table" in my schema.?ml file. Then all I do is rebuild the model, and - hey presto - I have a Propel object that relates to a view.
In some databases, providing your view only obtains its columns from one table, you can even write to it (ie an updateable view). On other databases, or if the columns come from a variety of tables, it is a good idea to set the Propel read-only tag in the schema, to prevent saves being attempted.
Remember Palestine
|
|
|
|
|
|
| Re: mysql operator hierarchy and propel [message #29232 is a reply to message #26553 ] |
Tue, 12 June 2007 22:51  |
east3rd Messages: 58 Registered: April 2006 |
Member |
|
|
|
Halfer, have you figured out a way to generate the "create view" statement necessary based on the readonly "table" in your schema? The problem is that every time I do a propel-insert-sql or a propel-build-all, my view gets destroyed, and I end up recreating it.
|
|
|