mysql - How can I simultaneously query all blog options table in a Wordpress multisite installation (3.0)? -


in our wordpress 3.0 multi-site installation, have custom option of our blogs called 'platform'. admins can enter in value platform when creating or editing blog. blogs may have no platform.

we need able create list of platforms, , associated blogs. problem is, dynamically create , delete blogs through other site mechanisms, have lots of blog options tables numbers not contiguous. (ie wp_2_options, wp_4_options, wp_12_options, etc.)

my question this, there way in wordpress grab option across blogs? conversely, there query run manually? i've tried no effect:

select * (select table_name information_schema.tables table_name 'wp_%_options') t option_name='platform'

does make sense i'm trying do? again, apologize lack of mysql knowledge, haven't been able find answers how this. query these table names first, , query each table separately, thats not option because have many blogs, , may need run query many page requests simultaneously, , adding hundreds of queries each of these requests.

any advice or guys give appreciated.

if want query directly mysql database, can create procedure , use it:

use wordpress; drop procedure if exists wordpress.myprocedure; delimiter | ; create procedure myprocedure (param1 varchar(30)) begin         declare tbname char(50);         declare endfetch int default 0;         declare cur1 cursor          select table_name information_schema.tables table_schema='wordpress' , table_name '%options';         declare continue handler sqlstate '02000'                 set endfetch = 1;         open cur1;         fetch cur1 tbname;         fetchloop: while not endfetch             select tbname ;              set @opt = param1;             set @table_name = tbname;             set @sql_text = concat('select option_value ',@table_name,' option_name=''',@opt,'''');             prepare stmt @sql_text;             execute stmt;             deallocate prepare stmt;              fetch cur1 tbname;         end while fetchloop; end | delimiter ; |   call myprocedure('siteurl'); 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -