$this->Model->id not working before saveAll in CakePHP

chapmanmoscow

New Member
I have the following code in CakePHP 2:\[code\]$this->Order->id = 5;\[/code\](note: I'm only setting the ID like this for debugging purposes... in my final code, I'll be checking to see if there's already a pending order with the current \[code\]person_id\[/code\] and doing \[code\]$this->Order->id = $var;\[/code\] if there is and \[code\]$this->Order->create();\[/code\] if there isn't.\[code\]$this->Order->saveAll(array( 'Order' => array( 'person_id' => $this->Session->read('Person.id'), 'amount' => $total, 'currency_id' => $code ), 'Lineitem' => $lineitems /* a correctly-formatted array */));\[/code\]I would expect this to update the row with the Primary Key of 5 in the \[code\]Order\[/code\] table and then insert the \[code\]Lineitem\[/code\] rows with an order_id of 5.However, all it does is create a new row in \[code\]Order\[/code\] and then use the new id from the new \[code\]Order\[/code\] record to create the \[code\]Listitem\[/code\] rows.Any idea what I am doing wrong here?
 
Top