homepage Welcome to WebmasterWorld Guest from 54.237.99.131
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Seeking for MySQL tables by regex
There's got to be a way to do this, but I can't find it
MatthewHSE

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3617724 posted 12:39 am on Apr 3, 2008 (gmt 0)

I've got a MySQL database with a little over 400 tables in it. I'm writing a script that needs to access about ten of these. The trouble is that those ten tables have what you might call dynamic titles, meaning they're created by other scripts periodically. This means I can't just hard-code the table names into my current script.

The tables in question do follow a consistent naming scheme - specifically, a three-letter word (they share the same one), followed by a random, unique, nine-digit number. No other tables in the database share this naming pattern.

How can I use PHP to scan the database for all tables that fit that pattern, without causing too much overhead?

Thanks in advance,

Matthew

 

cameraman

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3617724 posted 1:38 am on Apr 3, 2008 (gmt 0)

I was able to do this successfully:
SHOW TABLES WHERE Tables_in_database_name REGEXP '^f.*'

And I got the table names starting with f.
Alternatively you could use show tables to get them all into an array to regex them.

mjwalshe

5+ Year Member



 
Msg#: 3617724 posted 12:00 pm on Apr 3, 2008 (gmt 0)

when these dynamicly created tables are created just insert a row into a table that tracks thease dynamicly created tables.

have some sproc's that handle the dymincly created tables and handels the inserts/deletes etc

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved