I would like to know how to connect to the db and get the result of select query in wordpress. I mean i dont want to write the php db connection from scratch but use the wordpress way to the select query.
Thank you.
I would like to know how to connect to the db and get the result of select query in wordpress. I mean i dont want to write the php db connection from scratch but use the wordpress way to the select query.
Thank you.
What query are you trying to do?
i am actually doing a search function, search by post, user or tag.
I would like to write the query on selecting the crieteria..but i dont know how to start since i want to make use of the db setting in the existing wp.
Please advice.
Thank you.
Um, can't you look at one of the files and see how WP forms its queries?
If it's a plugin or whatever, the connection is already there.
put
require( dirname(__FILE__) . '/wp-config.php' );
at the top of your php file and then you can just use the mysql_query functions:
$sql = "select blog_id, path from wp_blogs where public=1 and spam=0";
$blogs = mysql_query($sql);
while ($blog = mysql_fetch_array($blogs)) {
..
..
..
}
Can't do the require as that file pulls wp-settings.php and off we go into wordpress. With errors. :)
I just add in the mysql connection manually myself. That's how I do all those little scripts that I do that sit outside of the mu install.