I have built an invoice system in my new CakePHP site and I am currently trying to build a function that will let me save the re-edited information back into the same records.
Below is the section of code I am working on,
$InvoiceDataVar = $this->data['Invoicedata'];
foreach ($InvoiceDataVar as $DataKey => $DataValue) {
$UpdateWork = $InvoiceDataVar[$DataKey]['workdes'];
debug($UpdateWork);
$this->Invoicedata->updateAll(
array('Invoicedata.workdes' => "'$UpdateWork'"),
array('Invoicedata.invoicejoblists_id' => $InvoiceID)
);
}
This is work $this->data holds,
'Invoicedata' => array(
(int) 0 => array(
'workdes' => 'test new update 1',
'price' => '500.00'
),
(int) 1 => array(
'workdes' => 'test new update 2',
'price' => '501.00'
),
(int) 2 => array(
'workdes' => 'test new update 3',
'price' => '503.00'
),
(int) 3 => array(
'workdes' => 'test new update 4',
'price' => '504.00'
),
(int) 4 => array(
'workdes' => 'test new update 5',
'price' => '505.00'
),
(int) 5 => array(
'workdes' => 'test new update 6',
'price' => '999.99'
)
)
These are of course just test data, but unless I am not understanding the UpdateAll function documentation which I have gone over many times, all this will do is update all the six fields with the last test input. Right now all the fields for the workdes contain, 'test new update 6'.
I should also say that there might not be all ways be six fields, there will always be at lest one, with a max (at this time) of 6 inputs to update.
I was thinking about loading the 'ID of the invoicedata table, which is an auto count number, where as the joblist_id is the same id in all the the fields being updated? This is my current line of thinking....
Any Help is most welcome.
Glenn.