Re: Code or Databases????
Hi Nate,On 10/25/06, nate <[EMAIL PROTECTED]> wrote: > This is interesting. I have these Modles, however my setup is Order HABTM> Item (link table Items_orders). Then when I want to add items to the order I> use bindModel to create a hasMany association between Order and ItemsOrder. > I'm interested to know why you chose the above associations?Those associations are based on an app I wrote about a year ago. I'vebeen doing some work on it recently, and the code has held up pretty well, so based on that I happen to think that's a good way to do it.I'm sorry, this isn't too clear. Just to be sure what do you mean by 'that'. The way I have it above or the way you posted? Cheers,Sonic> This is along the lines of what I had initially planned. How would the above > handle a port to PostgreSQL?I'm pretty sure Postgres supports both sub-selects and the SUM( )function, so I don't think you would do anything to port it, other thanchange your db connection 'driver' setting to 'postgres'. >> We're looking at some more advanced ways> > to build queries in Cake 1.2.>> This sounds great, as usual :)Well, we try. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
> This is interesting. I have these Modles, however my setup is Order HABTM > Item (link table Items_orders). Then when I want to add items to the order I > use bindModel to create a hasMany association between Order and ItemsOrder. > I'm interested to know why you chose the above associations? Those associations are based on an app I wrote about a year ago. I've been doing some work on it recently, and the code has held up pretty well, so based on that I happen to think that's a good way to do it. > This is along the lines of what I had initially planned. How would the above > handle a port to PostgreSQL? I'm pretty sure Postgres supports both sub-selects and the SUM( ) function, so I don't think you would do anything to port it, other than change your db connection 'driver' setting to 'postgres'. > > We're looking at some more advanced ways > > to build queries in Cake 1.2. > > This sounds great, as usual :) Well, we try. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
Hi Nate,Thank you for your input.On 10/25/06, nate <[EMAIL PROTECTED]> wrote: Theoretical Example: Order hasMany OrderItem, OrderItem belongsToOrder, Item:This is interesting. I have these Modles, however my setup is Order HABTM Item (link table Items_orders). Then when I want to add items to the order I use bindModel to create a hasMany association between Order and ItemsOrder. I'm interested to know why you chose the above associations? $this->OrderItem->find( 'Order.date BETWEEN "' . date('Y-m-d') . '" AND "' . date('Y-m-d',strtotime('-1 month')) . '"', 'SUM(Item.price) As total');This is along the lines of what I had initially planned. How would the above handle a port to PostgreSQL? If you wanted to calculate that including the tax per order, you couldeasily drop in a sub-select. Same question as above. We're looking at some more advanced ways to build queries in Cake 1.2.This sounds great, as usual :)Cheers,Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
Theoretical Example: Order hasMany OrderItem, OrderItem belongsTo Order, Item: $this->OrderItem->find( 'Order.date BETWEEN "' . date('Y-m-d') . '" AND "' . date('Y-m-d', strtotime('-1 month')) . '"', 'SUM(Item.price) As total' ); If you wanted to calculate that including the tax per order, you could easily drop in a sub-select. We're looking at some more advanced ways to build queries in Cake 1.2. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
Hi Chris,On 10/25/06, Chris Hartjes <[EMAIL PROTECTED]> wrote: That's a really great article. I've printed it out to read on thetrain ride home tonight. I'm doing some refactoring of an existingapplication (Rails, not CakePHP) and have to make some decisions about this very topic.Greatly appreciated.No probs. Let me know if it sparks off any ideas or methods you think I might be interested in.Cheers,Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
Hi Dieter,Thank you also for your advice. Much appreciated.I didn't want to use the custom SQL functionality as the chances are the same SQL won't be portable. This is only down to my own inexperience with the likes of PostGres and Oracle. I think I can live with the domain Logic instead. Cheers,Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
On 10/25/06, Sonic Baker <[EMAIL PROTECTED]> wrote: > Hi Chris, > > Thanks for your response. I guess to stick with cake's portability I'll do > these sort of tasks in the Domain logic. > > For future reference, if anyone's wondering about this question, and they > are good enough to search the list before posting, here's a link to help you > decide: > > http://www.martinfowler.com/articles/dblogic.html > That's a really great article. I've printed it out to read on the train ride home tonight. I'm doing some refactoring of an existing application (Rails, not CakePHP) and have to make some decisions about this very topic. Greatly appreciated. -- Chris Hartjes "The greatest inefficiencies come from solving problems you will never have." -- Rasmus Lerdorf @TheBallpark - http://www.littlehart.net/attheballpark @TheKeyboard - http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
This is an issue that comes back in many domains. my view on it , is basically: the more layers of abstraction you make to interact with a resource, the more simple that interaction becomes, but also, the more generic. And thus, the less you can optimize those interactions. (well offcourse you can, but then you wouldnt use the added abstraction) Often these layers of abstraction provide some way to expose the lower-laying power (for example cake lets you define your own sql queries) but that not only circumvents the added abstractions, it also makes your app less portable. You just have to make a compromise between RAD/portability/... and performance. imho, there is no magical solution that gives you both. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
Hi Chris,Thanks for your response. I guess to stick with cake's portability I'll do these sort of tasks in the Domain logic.For future reference, if anyone's wondering about this question, and they are good enough to search the list before posting, here's a link to help you decide: http://www.martinfowler.com/articles/dblogic.htmlCheers,Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Code or Databases????
On 10/25/06, Sonic Baker <[EMAIL PROTECTED]> wrote: > Hi there, > > I've read before that it's faster and even recommended to sum values at the > DB level through queries. So if I wanted to get a list of items sold between > certain dates, calculate tax totals, etc I should do this through queries. > > However, I'm not sure how portable it would be to do this through Cake's DB > abstraction layer as I'm not sure how other DBMS's handle summing functions > etc.. > > Has anyone any experience with this? What would you recommend? > > Cheers, Hi Sonic, Ah yes, you've hit upon one of the problems of using ActiveRecord/ORM wrappers...it's hard to do stuff beyond selects and joins with it, unless you are willing to write custom code to do it. I always try to get the DB to do as much work for me as possible. You can easily add on your own methods to the model classes to return the type of stuff you're looking for. But sometimes you just have to break down and create your own SQL to do something sort of tricky. Hope that helps. -- Chris Hartjes "The greatest inefficiencies come from solving problems you will never have." -- Rasmus Lerdorf @TheBallpark - http://www.littlehart.net/attheballpark @TheKeyboard - http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---