Fetching database query through function
Posted
by
Shubham Maurya
on Programmers
See other posts from Programmers
or by Shubham Maurya
Published on 2013-10-19T23:04:04Z
Indexed on
2013/10/20
4:12 UTC
Read the original article
Hit count: 249
I am sick of connecting database in each script i need a more OOP approach to fetching database results. ex like wordpress use wpdb class to fetch results.
This what wordpress does to get data
<?php $posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish'
AND post_type='post' ORDER BY comment_count DESC LIMIT 0,4")
?>
How can i create the same feature too using any class or function
and use it in my script
Thank you
© Programmers or respective owner