in reply to Abstracting SQL without Stored Procedures

Set up routines to:

a) Display x lines of table x starting at id x (or all the lines if nothing but table name given)
b) Make backup of table x to filename x
c) Restore table x from backup file x (or default backup, see below)

Then just include something which takes mySQL commands from a textarea and feeds them to the database, displaying any errors which occur as a result. Have the mySQL table automatically back itself up to another file before every set of commands, so the user can restore the database if he ruins it by mistake.

This should give someone who knows mySQL all the functionality he needs to maintain the database without complicated programming. As to actually using the database, that''s another story - you'll need something that people can include in their pages which lets them specify which fields they want displayed how:

ID=4 TABLE=PENPALS My name is <<NAME>> My email is <a href="mailto:<<EMAIL>>"><<EMAIL>></a>
ALL TABLE=PENPALS <tr><td><<NAME>></td><td><<EMAIL>></td></tr>
It would extract the field names, feed them to the database in a query, take the results, and display them. The first line could specify which or how many records of which table, and the rest of the lines would be the format to display in. Probably wouldn't be too hard to abstract.

Replies are listed 'Best First'.
Re^2: Abstracting SQL without Stored Procedures
by radiantmatrix (Parson) on Oct 10, 2004 at 06:40 UTC

    This would be great, if the SQL were entered each execute, or if I was interacting with a web page in any way. However, it is not and I am not.

    radiantmatrix
    require General::Disclaimer;