Buy Now
Sign in

Handling MySQL errors while querying a DB table through Custom Code

mapme , July 23 2019, 13:18
M
mapme 98
July 23 2019, 13:18 #388375
We are using a CF4 application to query data dynamically using a Custom Code.
Based on a URL parameter, we know which mySQL table/view to select. It works better than the DB Record Loader because it is unknown which table will be queried in advance. Everything works well, except in some cases the DB table may not exist. This causes an error as follows:
1146

Table 'databasename.#__tbl_1234_5678' doesn't exist

Is there a way to control this MySQL error message if the table doesn't exist? We want the page to keep loading rather than redirect to show this MySQL error.

Thanks.
GreyHead 64
July 23 2019, 13:27 #388376
Hi Mapme,
I guess that if you are using Custom Code then you can add a line to check that the table exists before you do the main data request.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much