My module uses the sql field (JFormFieldSQL) for a few simple queries in the database for a 3rd party component. My concern is that if the tables are missing, opening the module in the admin will "crash" the back-end, because of the error in the mysql (not finding the table).

Is there anyway to have the module in the backend checking if the table exists in db and if not to throw a notification that the necessary table is missing, and not continue loading the xml ?

2 Answers 2


Your concern is justified. Indeed, if there is an SQL error, the backend of the module will crash.

If this is a must have for you, I would look into extending the JFormFieldSQL with a custom implementation where you can check for SQL errors or do a MYSQL check like SHOW TABLES LIKE 'mycomponenttable'

See How to create a custom form field type in a module?


You can just check if the extension is enabled at the top of the module mod_.....php to prevent any further processing:

// Check for component
if (!JComponentHelper::getComponent('com_....', true)->enabled)
  • Hello Anibal, I have already this code in my module and it's only for the front-end, it's not applying for the admin of the module. The module will still be crashed, because of the error in the sql of the JForm SQL field.
    – FFrewin
    Commented Feb 7, 2015 at 18:54
  • But probably it could be used inside the custom field, to check for the component.
    – FFrewin
    Commented Feb 12, 2015 at 16:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.