Database Code Generator

DBCG v 5.0.4

Help Doc for Database Code Generator

Upload folder to server. Your done!

Make sure script is NOT accessable from internet!!! Requires Mod ReWrite be enabled on your server – typically is by default!!

Process Method

$_POST – Using the first column from the table as a trigger, [or Trigger column] this will run the $_POST variable though the "clean" function and then assign it to a variable named the same as the name of the column.

$_GET – Using the first column from the table as a trigger, [or Trigger column] this will run the $_GET variable though the "clean" function and then assign it to a variable named the same as the name of the column.

$_REQUEST – Using the first column from the table as a trigger, [or Trigger column] this will run the $_REQUEST variable though the "clean" function and then assign it to a variable named the same as the name of the column.

Database => Array

$key=>$val – This turns all the column names in to keys of an array whose value is from a variable named the same as the column name.

$key – Creates an array with auto-numeric keys whose value is from a variable named the same as the column name.

$val – Creates an array with auto-numeric keys whose values are the names of the columns.

Serialize – Creates an array using the column names as keys. Their corresponding values are from a variable named the same as the column name.

Unserialize – Unserializes an array and turns the column names into variables to hold the contents of the serialized array.

Database Echos

Echo Variables – Echo Variables

Connect

Connect – This pulls the credentials you used when logging into the database. This is a compact version. Credentials are not available through a variable. See [Alt] if you want credentials in variables.

Connect[alt] – This pulls the credentials you used when logging into the database. This is the long version. Most useful if you need to grab the credentials later in the script.

Insert

Insert – This runs all the variables [processed via POST] through the sql_val function and then into the database.
This is a compact version.
See [Alt] if you want a "long" version.

Insert [alt] – This runs all the variables [processed via POST] through the sql_val function and then into the database.
This is the "long" version.
See non [Alt] if you want a "compact" version.

Update

Update – Using the first column from the table as an identifier, this will update the database row that is equal to the identifiers value.
This is a compact version.
See [Alt] if you want a "long" version.

Update[alt] – Using the first column from the table as an identifier, this will update the database row that is equal to the identifiers value.
This is a compact version.
See [Alt] if you want a "long" version.

Select

Select One – Using the first column from the table as an identifier, this will grab all columns from a single row [the first one it finds] in the database that is equal to the value of the identifier.

Select Many – Using the first column from the table as an identifier, this will grab all columns from all rows in the database that is equal to the value of the identifier.

Select All – This will grab all columns from all rows in the database.

Search

Search Left – Search Left [%search]

Search Right – Search Right [search%]

Search Both – Search Both [%search%]

Delete

Delete – Which method to use depends on how you setup the form. Look at the method="" attribute of your form.

Miscellaneous

Copy Table Structure – This will copy the table structure so you can create another table without all the data.

Find & Show Duplicates – Queries the database to find duplicate information. The primary key is detected and used first, followed by the column you want to find the duplicates in.

Pagination – Pay attention!! This uses a wildcard search

Drop Down List

Drop Down List of Tables – While a bit odd – this creates a select field [drop down] with the names of the TABLES as the options. It uses the database name as the name of the select field.

Drop Down List of Columns – While a bit odd – this creates a select field [drop down] with the names of the COLUMNS as the options. It uses the table name as the name of the select field.

Drop Down List Generator – This will generate a drop down list on the fly.

Auto Increment

Next Auto Increment – the safe way – Safe way to get "next" auto increment id. This will insert a blank row into the database – securing the "next" auto increment number. Then once your done with your logic, rather than using an insert statement, update the blank row with your data.

Next Auto Increment – Drop this in your script to get the next auto incremental number.

Next Auto Increment [alt] – Drop this in your script to get the next auto incremental number.

Insert On Dup

Insert Into – On Duplicate – Update – This runs all the variables [processed via POST] through the sql_val function and then into the database – unless the indexed column value already exists, then it switches to an update statement.
This is a compact version.
See [Alt] if you want a "long" version.

Insert Into – On Duplicate – Update [alt] – This runs all the variables [processed via POST] through the sql_val function and then into the database – unless the indexed column value already exists, then it switches to an update statement.
This is the "long" version.
See non [Alt] if you want a "compact" version.

Connect

Connect – This pulls the credentials you used when logging into the database. This is a compact version. Credentials are not available through a variable. See [Alt] if you want credentials in variables.

Connect[alt] – This pulls the credentials you used when logging into the database. This is the long version. Most useful if you need to grab the credentials later in the script.

Insert

Insert – This runs all the variables [processed via POST] through the sql_val function and then into the database.
This is a compact version.
See [Alt] if you want a "long" version.

Insert [alt] – This runs all the variables [processed via POST] through the sql_val function and then into the database.
This is the "long" version.
See non [Alt] if you want a "compact" version.

Update

Update – Using the first column from the table as an identifier, this will update the database row that is equal to the identifiers value.
This is a compact version.
See [Alt] if you want a "long" version.

Update[alt] – Using the first column from the table as an identifier, this will update the database row that is equal to the identifiers value.
This is a compact version.
See [Alt] if you want a "long" version.

Select

Select One – Using the first column from the table as an identifier, this will grab all columns from a single row [the first one it finds] in the database that is equal to the value of the identifier.

Select Many – Using the first column from the table as an identifier, this will grab all columns from all rows in the database that is equal to the value of the identifier.

Select All – This will grab all columns from all rows in the database.

Count Rows – This will generate the code you would copy and paste into your script to show how many rows are in your table

Search

Search Left – Search Left [%search]

Search Right – Search Right [search%]

Search Both – Search Both [%search%]

Delete

Delete – Which method to use depends on how you setup the form. Look at the method="" attribute of your form.

Functions

Clean – Using the first column from the table as a trigger, [or Trigger column] this will run the $_POST variable though the "clean" function and then assign it to a variable named the same as the name of the column.

sql_val – Using the first column from the table as a trigger, [or Trigger column] this will run the $_GET variable though the "clean" function and then assign it to a variable named the same as the name of the column.

sql_key – Using the first column from the table as a trigger, [or Trigger column] this will run the $_REQUEST variable though the "clean" function and then assign it to a variable named the same as the name of the column.

reverb – Using the first column from the table as a trigger, [or Trigger column] this will run the $_REQUEST variable though the "clean" function and then assign it to a variable named the same as the name of the column.

print_x – Using the first column from the table as a trigger, [or Trigger column] this will run the $_REQUEST variable though the "clean" function and then assign it to a variable named the same as the name of the column.

Stats

Statistics

Form

Reverse Form – Paste a HTML form to generate database table

Table

Reverse Table – Paste a HTML table to generate database table

jQuery Source

jQuery fallback – jQuery

jQuery – jQuery

jQuery UI fallback – jQuery UI

jQuery UI – jQuery UI

Ajax

Full Page Ajaxed [Insert] – Full Page Ajaxed [Insert]

Full Page Ajaxed [Update] – Full Page Ajaxed [Update]

HTML Pages

Full Page [Insert] – Full Page [Insert]

Full Page [Update] – Full Page [Update]

Full Page Commented – Full Page Commented

Lists

Plain Text Table List – Creates a plain text list of all the TABLES in the database

Plain Text Column List – Creates a plain text list of all the COLUMNS in the table

HTML

HTML Form – This pulls the credentials you used when logging into the database. This is a compact version. Credentials are not available through a variable. See [Alt] if you want credentials in variables.

HTML – Prefilled – This pulls the credentials you used when logging into the database. This is the long version. Most useful if you need to grab the credentials later in the script.

HTML5

HTML5 Form – These are standard HTML5 forms

HTML5 Form – Prefilled – This runs all the variables [processed via POST] through the sql_val function and then into the database.
This is the "long" version.
See non [Alt] if you want a "compact" version.

Obfuscation

*HTML Form – Obfuscated* – Creates a standard HTML form using the column names as the "name" of each input field – except for the fact that they are encoded. You must use the special POST to convert the variables/names back into normal text.

*HTML Form – Obfuscated [alt]* – Creates a standard HTML form using the column names as the "name" of each input field – except for the fact that they are encoded. You must use the special POST to convert the variables/names back into normal text.

This alternative version adds the variable name before the code inside of a PHP comment so that it cannot be seen when someone views source via the browser, but when working with the file, you can see what it is.

Language

Change “en” to one of the other supported languages.

$language = 'en'; //en //de //es //fr //it //nl //pt //tr

HTML 5 Elements

If you have columns that you use that would like to be considered an HTML5 element, add your column name to the elements array.

For example: if you have a database column named “email_addresses” that you want this script to recognize it as an HTML5 email address, add it to the email array.
If you have a column named “domain” and you want this script to recognize that column as an HTML5 URL, add it to the URL array.

$html5_email = array("email_address");
$html5_url = array('domain');
$html5_tel = array("phone","work_phone","cell_phone","home_phone");
$html5_number = array();
$html5_range = array();
$html5_date = array();
$html5_month = array();
$html5_week = array();
$html5_time = array();
$html5_datetime = array();
$html5_datetime_local = array();
$html5_color = array();
$html5_textarea = array("notes");
$html5_pass = array();
$html_file = array("image");
$html_textarea = array();
$html_pass = array();
$html_readonly = array("id");
$html_disabled = array();

jQuery Versions

When you use Forms, jQuery, or Ajax forms it will use this version as default. You can always change it on the fly – this is just a base/fallback version number.

$jquery_jquery = '1.9.1';
$jquery_google = '1.9.1';
$jquery_micro = '1.9.1';
$jquery_local = '1.9.1';
$jquery_ui_jquery = '1.9.1';
$jquery_ui_google = '1.10.1';
$jquery_ui_micro = '1.9.2';
$jquery_ui_local = '1.10.1';

Cache

Enables caching of menu

$cache = 0; // 0 for no cache, 1 for cache

Tooltips

Enable or disable tools tips. Can also be done from front end. If you disable them here, front end cannot enable them.

//dont forget to delete the 'dbcg_assets/cache/_menu.php' file if you have enabled caching.
$tooltip = 'tooltip';// empty for no tool tips. 'tooltip' to enable tool tips

Login

Add quick logins if you want them to show up in the dropdown.

$log_in_sets = array( //to setup login sets follow this example
//"Set_Name" => array('Host', 'Database', 'UserName', 'Password') //dont uncomment this unless you want it to show up on the front end!!
"Demo_1" => array('localhost','Data_Base','User_Name','P@s5W0rD'),
"Demo_2" => array('localhost','Data_Base','User_Name','P@s5W0rD'),
);

TimeZone

Not really important, but adjustable

ini_set('date.timezone', 'America/Chicago');
date_default_timezone_set('America/Chicago');
putenv("TZ=US/Central");

Error Display

Not really important, but adjustable

ini_set('display_errors',true);
ini_set('error_reporting',E_ALL);
error_reporting(E_ALL);

Debugger

Not really important, but adjustable

$debug = 0;

Autocomplete

Not really important, but adjustable

$autocomplete = "off";

DO NOT EDIT

DO NOT EDIT

include 'dbcg_assets/lang/db_code_gen_'.$language.'.php';

if (file_exists('dbcg_demo.php')) {
include 'dbcg_demo.php';
}