symfony
symfony forum
Home » support » General discussion » mysql operator hierarchy and propel
mysql operator hierarchy and propel [message #21955] Mon, 19 February 2007 10:34 Go to next message
searaig  is currently offline 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 #21963 is a reply to message #21955 ] Mon, 19 February 2007 11:24 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9514
Registered: January 2006
Location: West Midlands, UK
Faithful Member
That's a Propel question, and it's a good idea. It's outside the scope of symfony development though - you should send this to the Propel/Creole development list.

http://propel.tigris.org/servlets/ProjectMailingListList


Remember Palestine
Re: mysql operator hierarchy and propel [message #21998 is a reply to message #21963 ] Mon, 19 February 2007 18:59 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
i agree that the sql issue is a propel question.

i guess then my real question is how do i bypass the use of the Criteria() object to populate my classes with data?
Re: mysql operator hierarchy and propel [message #22016 is a reply to message #21955 ] Mon, 19 February 2007 23:00 Go to previous messageGo to next message
halfer  is currently offline 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 #22023 is a reply to message #21955 ] Tue, 20 February 2007 03:16 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
sweet and that doesn't even look hard!

Re: mysql operator hierarchy and propel [message #22057 is a reply to message #21955 ] Tue, 20 February 2007 12:50 Go to previous messageGo to next message
halfer  is currently offline 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 #26536 is a reply to message #21955 ] Wed, 02 May 2007 10:54 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
i'm not sure i know what you mean when you say "i write a view"
Re: mysql operator hierarchy and propel [message #26553 is a reply to message #21955 ] Wed, 02 May 2007 13:16 Go to previous messageGo to next message
halfer  is currently offline 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 #26586 is a reply to message #21955 ] Wed, 02 May 2007 19:52 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
gotcha, i've done that kind of thing with sql server. is this possible with MySQL?
Re: mysql operator hierarchy and propel [message #26627 is a reply to message #21955 ] Thu, 03 May 2007 11:35 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9514
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Apparently so, on MySQL 5 (I used Google to answer your question!). Also what I didn't know was that *some* multiple-table views can be updatable too:

http://dev.mysql.com/doc/refman/5.0/en/create-view.html


Remember Palestine
Re: mysql operator hierarchy and propel [message #26631 is a reply to message #26627 ] Thu, 03 May 2007 11:53 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
this is evolution!!!
Re: mysql operator hierarchy and propel [message #29232 is a reply to message #26553 ] Tue, 12 June 2007 22:51 Go to previous message
east3rd  is currently offline 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.
Previous Topic:Memory issue with propel
Next Topic:When to use project/app/module
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software