thefortrees Posted June 21, 2007 Share Posted June 21, 2007 Hi all - I am writing a dynamic customer service application that generates questions based on the kind of business, customer, etc and I have a functions.php that contains at least 15 functions, but they are all mysql queries. I return the result of the query in each of tehse functions. Is it good practice to to return results of queries in functions? Quote Link to comment https://forums.phpfreaks.com/topic/56541-function-conventions/ Share on other sites More sharing options...
Buyocat Posted June 22, 2007 Share Posted June 22, 2007 Well every application which uses a database has to have some component which returns results of SQL queries, so it's not bad practice. What's trickier is deciding what to return and how to format it. One approach would be to return all result sets as an array, and updates/inserts as a boolean. It may be helpful to look at PDO (from the php.net documentation), ADODB (google it's site), and MDB2 (under PEAR) to see how they handle the problem. Quote Link to comment https://forums.phpfreaks.com/topic/56541-function-conventions/#findComment-279730 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.