Error Handling with very basic SQL query |
Hi Guys,
I have built this simple code which uses a specific database configuration and then runs SELECT query on the EMPLOYEE table. This table has very huge database and I believe because of that, the db is throwing error. Which is fine. Below is my code. I have done the error handling code in this but it still throws attached error on browser. I want it to suppress throwing error on browser and catch it into variable so I can display it properly. Because I would like to use this code for an API server. Ignore the part where the code is commented for $DB_MYSQL. That is for future use, I am going to switch database on specific occassions. PHP Code: $DB_MSSQL = $this->load->database('mssql_db', TRUE);
CodeIgniter User Guide - Database
PHP Code: if ( ! $this->db->simple_query('SELECT `example_field` FROM `example_table`')) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@aslamdoctor,
Specifically, what database error is being given? Also, have you run your query directly in the database to make sure that it works? Also, you may be maxing out the expected output so you may need to reset a PHP ini setting (post_max_size or memory_limit). Just a thought. Have you checked the CI logs?
(04-21-2019, 11:08 AM)php_rocs Wrote: @aslamdoctor, Regarding db error, looks like my attachment was not posted in approval process. Sending here http://i68.tinypic.com/jaw5e9.jpg Yes I ran the query directly in db and it worked fine. I know the records it returned is Huge and that is definitely the reason why error is coming. But issue is not the error, issue is how can I catch that error in the variable instead of just throwing the big CI standard error on screen?
@aslamdoctor,
Maybe this will be helpful to you https://codeigniter.com/user_guide/datab...ing-errors Also, I did find this link as well (a try catch statement) https://stackoverflow.com/questions/3418...deingniter
(04-22-2019, 01:16 AM)php_rocs Wrote: @aslamdoctor, If you check my code, I have already used similar code as per the user guide link you sent. In try catch method, I can only put my own error text. But can not get the actual error in a variable or something like that.
See if this will work for you.
php.net - mssql_get_last_message Identifying Critical Error Messages in MS SQL What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Didn't see that sorry.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |