My MySQL Database Editor
Purpose
To easily allow me to update test databases I am working on without needing to use the mysql command line or write a custom web page... this script can just be pointed at a database and it will be able to display/add/update/delete entries from any table in the database.
The script does not need to know anything about the database, it will use MySQL queries to find what tables are in the database and let you select a table to edit; after which it will query the table to determine column names and attributes to use in update forms.
I have never used "phpmyadmin" and this is not intended to replace it (I believe that is a powerfull tool,
at least many of the hacker attempts against by website are searching for phpmyadmin).
This tool was written for my needs to specifically make it easier for me to update a database(s) easily
as needed when I am testing, and is there to 'plug in' while testing and remove when done. It is not a
database management tool, it is simply a tool to make life easier when testing.
Functional Notes
- does not need to know the tables in the database, will work it out
- does not need to know the number, names, formats of columns in the tables, will work it out
- will enforce table column type structure in update forms
- if a column is "char" or "varchar" max input length for the data entry page form is set based on the character length of the table column
- if the column is an "int" the input field on the data entry page will use the html5 tags "numeric","min" and "max" to control what is allowed to be input (min will be 0, max will be 999.. (all nines for the length of the column, ie: if the column was defined as int(5) max would be 99999)
- if the column is a "enum" type then all enum values defined for the column are placed into a "select list" on the data input form to prevent any illegal value being provided
- if the column is defined as being "not null" then the html5 required=required tag is assigned to the field to ensure it is provided
- if an update request is being done the input form will be populated with the current contents of the table entry being updated, including correct selection of current enum values if they are present in the table; additionally the key field will not be updateable on the form, as letting a key change on an update is always a bad thing
Current Limitations
The script only does special input field handling for "char", "varchar", "int" and "enum" type fields. Any other field type will be set as a normal html textarea field for add/update requests.
Not really a limitation as everything will still work, assuming your database doesn't store images or large blobs of course.
Getting the current version if you want it
The mysql_tool.tar.gz file has two files. mysql_tool.php is the database script itself which just needs to be copied somewhere your webserver can find it. dbs_include.php is the include file that contains the database name, userid and password for the database you intend to work on, the script expects that in the same directory you placed mysql_tool.php but you should probably update the script to put it in a more secure place unless this is just for test server use.
Update the dbs_include.php with the details of the database you wish to run it against, use your web browser to access mysql_tool.php, and your database updating can begin.
The todo list
Well I'll never allow an input form for database name, user and password, as user and password must never leave the server.
Have been wondering if instead of a database table selection page being
the first page displays I should change it to a database selection
page (as only databases acessable to the user will be available anyway)
that can then drop down to the table selection page.
But I don't need it yet and I tend to drop a copy of this into
application directories I am working on, don't want to make a
development tool too generic, so probably will not do that as it will
only take about 10mins including testing so no fun there and I don't need it.