Jump to content

function conventions


thefortrees

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/56541-function-conventions/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/56541-function-conventions/#findComment-279730
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.