how to catch database errors in model |
i am using a method '$this->db->_error_message()'
i am writing the below code in my model public function deal_citys($deal_id) { $query=$this->db->query("select deal_location from deal where deal_id=$deal_id")->result(); if ($query) { return $query[0]->deal_location; } else { $this->db->_error_message(); } } i am not passing to deal_id in my controller. how can i catch the db errors in codeigniter please give me a examples
If you have db_debug set in your database config, you won't really get a chance to catch the errors.
$this->db->_error_message() only works in CI2. CI3 does include an error() method in the db class to get the most recent error, if any have occurred: http://www.codeigniter.com/user_guide/da...ing-errors So, you would do something like this: PHP Code: public function deal_citys($deal_id) |
Welcome Guest, Not a member yet? Register Sign In |