Is there a way to get a list of cms tables that already exist?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 18, 2012   (RSS)

Re: [garyhoffmann] Is there a way to get a list of cms tables that already exist?

By gregThomas - September 18, 2012 - edited: September 18, 2012

Hi Gary,

This is a good question, and we've found a solution to it! If you use this MySQL code for the get options from MySQL query option on the list field type:

SELECT REPLACE(TABLE_NAME, '<?php echo $TABLE_PREFIX;?>', '') FROM information_schema.`TABLES` where TABLE_SCHEMA = '<?php echo $GLOBALS['SETTINGS']['mysql']['database'];?>' AND TABLE_NAME like '<?php echo $TABLE_PREFIX;?>_%'

This should get the all of the table names from the information_schema table, and uses the MySQL replace function to remove the 'cms_' part of the table name in the results. It should all be dynamic so you shouldn't have to change anything in the code above.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Is there a way to get a list of cms tables that already exist?

By garyhoffmann - September 18, 2012

Works perfectly!!!

Thanks so much - I will begin replacing all instances of my entry fields with this - it will be very nice. I have this concept in literally 10-15 places throughout my "normal" site setup. This will be so nice.

Gary.