son.of.the.morning Posted December 1, 2011 Share Posted December 1, 2011 Hey guys I want to create a class containing a SELECT statment in order to make in re-usable though out my entire applicion. Any one no a good way to go about this? This is the native way i have done it. I want to be able to make this into a class becuase i have more than one database with the same tables. $articles = "SELECT * FROM blog_posts INNER JOIN users ON blog_posts.aurthor_id=users.user_id INNER JOIN post_categories ON blog_posts.category_id=post_categories.id"; $articles_results = mysql_query($articles)or die(mysql_error());; Quote Link to comment https://forums.phpfreaks.com/topic/252204-a-php-class-for-mysql-select/ Share on other sites More sharing options...
trq Posted December 1, 2011 Share Posted December 1, 2011 You could wrap that in a simple function. What makes you think a class is what you need? Quote Link to comment https://forums.phpfreaks.com/topic/252204-a-php-class-for-mysql-select/#findComment-1292987 Share on other sites More sharing options...
son.of.the.morning Posted December 1, 2011 Author Share Posted December 1, 2011 Well i want to be able to re-use all my backend design in other blogs i will creat in the futore Quote Link to comment https://forums.phpfreaks.com/topic/252204-a-php-class-for-mysql-select/#findComment-1292994 Share on other sites More sharing options...
trq Posted December 1, 2011 Share Posted December 1, 2011 Tying queries to a class does not make them re-usable. A simple function will server the same purpose, even then, I would say your compromising flexibility. Quote Link to comment https://forums.phpfreaks.com/topic/252204-a-php-class-for-mysql-select/#findComment-1292996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.