Database Code Generator (Database Abstractions)

Database Code Generator:

Upload a single file to the server you are developing on and log into the SQL Server with Step 1.

The script will pilfer your database and generate a list of tables for Step 2. Simply select the table you want to work with from the drop-down.

Step 3 will populate a drop-down list of all 16 options you can use to save yourself time in development by copy and pasting the generated code into your script(s).

In step 3; if you select a form operation a button will be available at the end of the results box where you can preview your form.

Forms

This script will look to see the “type” of column that is in the database to determine the maxlength of the input fields. If the column is an INT or VarChar [or whatever] with a length of 8 then the maxlength of that particular input field will also be 8.

If the column type is “text, mediumtext, longtext, blob, mediumblob, or longblob” instead of using a text input, it will use a textarea.

HTML5 Forms

This script will match up column names with HTML5 input types to determine the type of input to use. For example: A valid input type for HTML5 is “email” – so, if the name of the column in the database is called “email” this script will use that HTML5 input type. HOWEVER , if the column name is e_mail – the script will give it a “text” input type unless e_mail is a custom column name (see box below).

HTML5 Custom Forms Types

Edit the php file. At the top you will see a list of arrays. Putting the name of your column in the appropriate array will trigger that column to be recognized as HTML5 type when the “Custom Column” checkbox is checked.

Example: Lets say you have a column named “phone” that is used to store phone numbers, and you want that input field to be a HTML5 type of “number”.
$html5_number = array("phone");
By adding “phone” in the $html5_number array when you select HTML5 from the Opt dropdown, any column with the name of phone will be assigned the HTML5 input type of “number” when the “Custom Column” checkbox is checked.

To see the custom arrays in action:

In the live demo I have a table called “demo”. In that table is a column named “notes” – it is a VarChar with a 128 character limit.
Go to the live demo and click Submit.
In Step 2 select the table : “demo”
In Step 3 select the operation : “Form – input”
Wait for the results to show up and look at the [last] input named “notes”. You will notice that it is a text input.
Now place a checkmark in the “custom columns” checkbox.
Wait for the results to update and look at the [last] input named “notes”. You will notice that it is now a textarea.

Updates

  • Version 1.0 – Initial Release – Oct. 24th 2011

Download Database Code Generator (Database Abstractions)

Leave a Reply

Your email address will not be published. Required fields are marked *