Fetching database query through function
- by Shubham Maurya
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