0

Cakephp 1.2.6 and Postgresql 8

I run cakephp on shell. I used save(). There are some error from Postgresql, I would like to keep that error in another database. Who knows command in Cakephp or Postgresql that can be keep that error as string?

example:
if($this->Model->save($data)) { 

}
else {
/// command??
}
3

2 Answers 2

1

Thanks PresleyDias

Try & Catch not work for me. Now, I used this method:

 $this->getDataSrouce()->error;

for getting last error from DB.

from : http://www.sanisoft.com/blog/2011/07/05/how-to-track-sql-errors-in-cakephp-on-production-site/

Sign up to request clarification or add additional context in comments.

Comments

0

if you want to catch the exception and then save in the database then you can use somethin like this

   try {

         if($this->Model->save($data)){
                       //do somthing
             }

        //now the exception occured.. so catch it
       }catch (Exception $ex){

             // this message is  "ERROR: ". $ex->getMessage()
             //save the message here to the other database where the message is    $ex->getMessage() 
       }

from Stackoverflow also cakephp-exception and cakephp-throw-exceptions

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.