Try:

$this->Company->Setting->id = $settingid; // Make sure this is the
unique id of the setting row you are trying to edit
$this->Company->Setting->saveField('invoice_number', $invoice_number
+1);
http://api.cakephp.org/class/model#method-ModelsaveField

Assuming $invoice_number is your newly created invoice number.

Alternatively, if you are inserting a new invoice record every time,
you could also use the counterCache Model feature to automatically
increment your invoice_number field. You would need to rename it to
invoice_count however:
http://book.cakephp.org/view/75/Saving-Your-Data#counterCache-Cache-your-count-816

On Apr 14, 3:38 am, Matt <[email protected]> wrote:
> So I have an invoice model and a setting model. When the user creates
> a new invoice, I need to automatically change the invoice_number to
> one more than the current in the Settings model.
>
> I figured out that the code below will create a new row in my
> database, but I need to figure out how to simply modify the existing
> row. Please help!
>
> $this->Company->Setting->save(array('invoice_number'=>'999'));
> $this->Company->Setting->save();
>
> Thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to