Sql-request to sort blogs by order in wordpress mu? -
Sql-request to sort blogs by order in wordpress mu? -
i'm using next code generate list of wordpress blogs in wordpress mu network:
$blogs = $wpdb->get_results("select * " . $wpdb->blogs . " last_updated!='0000-00-00 00:00:00' , public='1' , spam = '0' , deleted ='0' order registered " . $order . " limit " . $limit); how do order them alphabetically instead of when registered? if not familliar database layout of wordpress, i'd happy coneptual explanation! name not registered in same database, how blogname collected output:
foreach ($blogs $blog) { $blog_options = "wp_" . $blog->blog_id . "_options"; $blog_name = $wpdb->get_col("select option_value " . $blog_options . " option_name='blogname'"); }
without knowing wordpress database schema:
if there unique blog id in both $wpdb->blogs table , $blog_options table, can bring together between them, (pseudocode):
select [...] $wpdb->blogs left bring together (select id, option_value blogname $blog_options option_name='blogname') b on a.id = b.id last_updated!='0000-00-00 00:00:00' , public='1' , spam = '0' , deleted ='0' order blogname [... etc ...] in query, you've joined each blog associated blog_option record optionname='blogname'. inner query in bring together returns option_value alias 'blogname', can reference in order clause.
you'll have work query bit based on actual database schema, it's start!
sql wordpress
Comments
Post a Comment