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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.