Dr. Loboto, I tried your suggestion and error for undefined property
$connection has gone away, but the method lastError() returns a NULL.
Here is the code snippet from the controller:
$this->Model->create($data);
$db_object=$this->Model->getDataSource();
$this->Model->saveAll($data, array('validate'=>true, 'atomic'=>true));
pr($db_object->lastError());On Sep 16, 6:12 am, "Dr. Loboto" <[email protected]> wrote: > You should call lastError() on model datasource: $this->getDataSource > ()->lastError(), same for other DboMysql methods. > > On Sep 15, 6:39 pm, senser <[email protected]> wrote: > > > Hello, > > > I'm trying to find a way to get errors occurred when executing SQL > > queries for adding, editing or deleting rows and show them in view. > > There is a method in DboMysql called lastError() but when calling it I > > receive an error: "Undefined property: ***::$connection". There is a > > callback method onError() in model too, but I can't find how to use it > > to receive sql error. > > For example: User want to save new row in database table. Row data > > passes validation rules but when Cake tries to save it to mysql, > > server returns an error for duplicate entry in some row field - I need > > to show that error to user. > > > 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 -~----------~----~----~----~------~----~------~--~---
