Hi. I am constructing a somewhat generic class to contain all queries needed to make a self sustaining base to conform for a larger purpose.
Basically I am quite new to the concept of writing classes, which doesn´t have much to do with this inquiry though. One of the issues I ran into was how to handle possible multiple selections from an sql query without putting in a lot of if statements or switches to accomodate this. Instead I´ve taken the approach of using the "explode/implode" array handler to overcome this. Consider a very simple query: "SELECT foo,bar FROM table ORDER BY foo asc;". Suppose the "foo" and "bar" was assigned to the array "fields" in the HTML form (the fields would of course be checked against the table and that sufficient privileges existed for the logged in user, before trying to perform the query.), would the "$selected_fields = implode(",",$fields);" followed by "$sql_query = "SELECT $selected_fields FROM table ORDER BY foo asc;";" be a proper way of handling this issue or am I in over my head? Cheers, Henrik J.