Update "Properties" model when adding a new record in CakePHP

Posted by Paul Willy on Stack Overflow See other posts from Stack Overflow or by Paul Willy
Published on 2010-04-27T16:13:20Z Indexed on 2010/04/28 15:03 UTC
Read the original article Hit count: 313

Filed under:
|
|

Hi,

I'm writing an application in CakePHP that, for now, is to be used to make quotes for customers. So Quote is a model. I want to have a separate model/table for something like "Property," which may be used by other models.

Each time a user gets to the "Add Quote" action, I basically want to pull a Property called "nextQuoteNumber" or something along those lines, and then automatically increment that property, even if the new Quote isn't saved. So I don't think just using an autoincrement for Quote's id is appropriate here - also, the "quote number" could be different from the row's id.

I know this is simple enough to do, but I'm trying to figure out the "proper" CakePHP way of doing it! I'm thinking that I should have a method inside the Property model, say "getProperty($property_name)", which would pull the value to return, and also increment the value... but I'm not sure what the best way of doing that is, or how to invoke this method from the Quotes controller.

What should I do? Thanks in advance!

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about php