I just upgrade my project to Phalcon 2.0 yesterday, and my source got geting an error:
Phalcon\Mvc\Model\Message Object
(
[_type:protected] => InvalidUpdateAttempt
[_message:protected] => Record cannot be updated because it does not exist
[_field:protected] =>
[_model:protected] =>
)
And here is my code:
$invoice = Invoices::findFirst([
'conditions' => 'display_id = :id:',
'bind' => ['id' => $params['invoice_id']]
]);
$invoice->transaction_id = $paypalResponse['PAYMENTINFO_0_TRANSACTIONID'];
$invoice->paid_at = date('Y-m-d H:i:s');
$invoice->payer = $tranDetails->PayerInfo->Payer;
$invoice->payer_status = $tranDetails->PayerInfo->PayerStatus;
$invoice->status = 'Paid';
$invoice->user->increaseBalance($invoice->credit);
$invoice->update();
foreach ($invoice->getMessages() as $msg) {
print_r('<pre>');
print_r($msg);
print_r('</pre>');
}
When I change to use save(); it working but I don't know why update() working on 1.3.4 but not on 2.0. Some people have same issue: https://github.com/phalcon/cphalcon/issues/2981