I have a lot of repetitive code that inserts and selects data from my MySQL database. Out of curiosity, is it possible to create a PHP function that can take the table
, columns
, and rows
as parameters and generate the SQL statement. A completely dynamic SQL statement generator, if you will.
For example:
function PushData($table, $columns, $values)
{
// insert data
}
Furthermore, is the opposite possible. A function that can select and return data.
function PullData($table, $columns, $rowID)
{
// grab data
return data;
}
Is something like this possible? If so, would this be something worth doing?