MySQL interface. Create forms to insert, update and search. Embed tables or single values into pages. Foreign keys. Password records. Send email.
Putting "[abase]" on a page will display the current ABASE version, the default database, default user and a list of all the accessible database tables. Add attributes to access MySQL databases, create forms, display tables, and create Internet database applications in WordPress.
From the Details screen before you install ABASE, complete shortcode and attribute documentation can be found in the Description section. Once installed, from the WordPress Admin section, click Settings on the left, and then "ABASE for MySQL." This is also where you set the database and user. Below that is the most up-to-date reference guide for ABASE.
In the WordPress Admin section, clicking Settings on the left, then "ABASE for MySQL" will show the configuration settings. This confirms the installation.
Another way is to place the shortcode [abase] in a page or post and it will display the current user and database settings. If the database contains any tables, their names and record counts are listed.
There is no limit. Note that a shortcode [abase] is different than [ABASE]. This is important if you embed an ABASE shortcode within another, e.g., [ABASE] ... [abase /] ... [/ABASE] works.
In the WordPress Admin menu, click Settings on the left, and the ABASE for MySQL.
This step is performed outside ABASE. If you have cPanel, you can create a new database using the MySQL Databases or MySQL Database Wizard cPanel applications. Otherwise you can use the default WordPress database and create your own tables using the SQL CREATE TABLE statement.
ABASE can connect to up to 9 databases. You change or add a database in the WordPress dashboard by clicking Settings on the left, then clicking on ABASE for MySQL. ABASE defaults to the first database. If no database is specified, it defaults to the WordPress database. If no user is specified it defaults to the WordPress user. It is recommended that you create your own database not use the WordPress database. You can create your database and give the WordPress user access using the MySQL Create Database application. To connect a second or third database you may need to Expand to full settings first.
ABASE shortcodes default to using database 1. A db="1", db="2", db="3", up to a db="9" attribute in a shortcode will specify a specific database to use AND change the default database for the remaining shortcodes on the page. Therefore if the page uses database 2, you only need to specify [abase db="2"] in the first shortcode. Shortcodes [abase2 ...] will use the database 2 regardless of the default, and will not change the default. Shortcode [abase3 ...] will use database 3 and not change the default.
You can use phpMyAdmin, which is available in cPanel. You can also use the CREATE TABLE SQL statement in an ABASE shortcode using the sql="?" attribute.
For example, shortcode:
[abase sql="CREATE TABLE employees (
employee_id int(11) NOT NULL AUTO_INCREMENT,
first_name varchar(100) NOT NULL,
last_name varchar(100) NOT NULL, PRIMARY KEY (
will create a table named 'employees' in the current database, with a primary key ID field named 'employee_id' and a first name field named 'first_name' and a last name field named 'last_name'. The primary key is autoincrement and the first and last names can each be up to 100 characters long.
There are different ways, depending on what you want to display.
[abase table="employees"] will display all the columns and all records in the employees table. If there are any foreign keys columns from those tables will also be displayed.
[abase table="employees" columns="first_name,last_name" ORDER="last_name,first_name"] will display only the first and last name columns in alphabetical order by last name.
[abase sql="SHOW COLUMNS FROM employees"] will display the structure of the employees table.
[abase sql="SHOW CREATE TABLE employees"] will display the SQL CREATE statement to create the table.
To make the Title come from a separate Titles table, create your Titles table so it uses the InnoDB storage engine.
[abase sql="CREATE TABLE titles (title_id int(11) NOT NULL AUTO_INCREMENT, title_name varchar(50) DEFAULT NULL, PRIMARY KEY (title_id)) ENGINE=InnoDB"]
Make your employees table InnoDB also and add the column that will contain the foreign key.
[abase sql="ALTER TABLE employees ENGINE = INNODB"] [abase sql="ALTER TABLE employees ADD title_key INT NOT NULL, ADD INDEX ( title_key )"]
Finally, set the foreign key relationship.
[abase sql="ALTER TABLE employees ADD FOREIGN KEY ( title_key ) REFERENCES titles (title_id) ON DELETE RESTRICT ON UPDATE RESTRICT"]
[abase form="1,insert" table="employees" columns="first_name,last_name$Add Employee" elements="first_name,last_name" ack="red"]
The form attribute specifies a form to insert records, and the "1" indicates this form consists of only 1 shortcode (this one). The elements attribute specifies which fields are form input elements and the columns attribute specifies which fields are displayed and their formatting. The "$Add" specifies the submit button following the color field, with "Add" being the button text. The elements attribute specifies the first_name and last_name fields will be form input elements. The ack attribute requests an acknowledgement be displayed in red when data is inserted.
Formatting takes place in either the columns, fields or cols attribute. Changing the title of a column precedes the name with a carrot (^) character. Element formatting follows the name with an exclamation point (!) in single quotes ('). Within the single quotes can begin optionally with the type of form element followed by a space, then either (a) 1, 2 or 3 integers separated by semicolons, or (b) contents of an HTML style attribute. 1 to 3 integers correspond to width, height and vertical-align values in pixels. An HTML style attribute can specify width, height, vertical-align, font-size, font-family, and anything else. For example,
[abase form="1,insert" table="employees" columns="first_name!'width:100px;font-size:12pt;',Password^last_name!'password 100;15'$Add Employee" elements="first_name,last_name" ack="red"]
The format of the first name field will be a text box 100 pixels wide and the font size will be 12 point. The height defaults to 18 pixels. The last name field will be renamed on the form "Password" and the form element will be a password type (so what is typed on the screen is hidden). The password form element will be 100 pixels wide and 15 pixels in height.
To specify a search form using ABASE, you will use at least the table="?", columns="?", elements="?" and form="?" attributes. If you would like your search results to appear on the same page, you do not need to specify the URL page of the search results in the form="" attribute.
[abase form="1,search" table="employees" columns="first_name,last_name$Search Employees" elements="first_name,last_name"]
In this example, if the search results were to appear on a different page, the form="" attribute will be form="1,search,/search-results/" where /search-results/ addresses the search results page.
On the searh results page, place the following shortcode to display a table with the results of the search. This example shows the use of the optional where="" attribute to restrict the search to records with
status='1'. With the optional attribute echo="0" the user can view the page source and see the complete SQL statement for the search in the HTML comments.
[abase table="employees" columns="first_name,last_name" where="AND
status='1'" echo="0" ack="green"]
First you need a way to identify the record you want to update. To do so, we can use the rlink attribute to specify the first name as a "record" link.
[abase table="employees" columns="first_name,last_name" rlink="first_name" echo="blue"]
The first name will appear as a link. Clicking on a link first name will re-display the page with the primary key and value in the query string. To create the form, place the following shortcode on the same page.
[abase form="1,update" table="employees" elements="first_name,last_name" fields="first_name,last_name$Update Employee" ack="brown" echo="blue"]
When a record identified by its primary key is in the query string, an update form for that record will be produced.
The execution results from a shortcode execution is sent as an email if there is a valid emailto="<email_address>" attribute is present. <email_address> can be either an actual email address or a column name that contains valid email addresses. If an email address is specified as a column, the email will be sent if the shortcode execution results in exactly one record. If the email is sent, the content will not display on the page.
To produce more readable email content, add a <content> field followed by a [/abase] closing shortcode, and <content> will appear before the original shortcode output.
For example, the following ABASE shortcode will send an email to firstname.lastname@example.org that says "Hello Joe, how are you?"
[abase emailto="email@example.com"]Hello Joe, how are you?[/abase]
Replace firstname.lastname@example.org with your email address and view the page with the shortcode. You should not see the email content on the page but you should get the email.
ABASE shortcodes can be placed within <content> as long as the ABASE shortcodes within <content> use "ABASE" if the email shortcode uses "abase" (or vice versa). So, for example, the following shortcodes will email the contents of the employee table:
[ABASE emailto="email@example.com"] Joe, here is the contents of the employee table: [abase table="employees"] Fred. [/ABASE]
Use an SQL statement. For example, to add an integer field "employee_level" to the employees database, execute the following just once:
[abase sql="ALTER TABLE
employee_level INT NOT NULL"]
Once the page containing the shortcode is displayed (and the new field added to the table) then be sure to delete or disable the shortcode so it doesn't execute again.
File uploads are associated with a field in a database record. When uploading a file, the file is stored in a directory defined by the table name, column name and primary index. The address of the file (path and file name) is stored in the table cell defined by the table name, column name and primary index. The images or files attribute specify columns that correspond to file uploads.
For example, if we start by creating a table as follows with an employee first name, last name and picture:
[abase sql="CREATE TABLE
employee_id int(11) NOT NULL AUTO_INCREMENT,
first_name varchar(100) NOT NULL,
last_name varchar(100) NOT NULL,
picture varchar(250) NOT NULL, PRIMARY KEY (
A form to add an employee with the picture field identified as an image would produce a browser file upload form element for the picture entry:
[abase form="1,insert" table="employees" elements="first_name,last_name,picture" columns="first_name!'100',last_name!'100',picture!100$Add Employee" images="picture" ack="green"]
Displaying the employees table with pictures would be as follows:
[abase table="employees" columns="picture!'width:50px;vertical-align:-25px;',first_name,last_name" images="picture" style="width:500px;"]
The images attribute declares picture as an image. The exclamation point (!) precedes formatting for the image. width:50px will resize the image to 50 pixels wide and vertical-align:-25 will lower it 25 pixels so the adjacent rows will appear in the middle instead of at the bottom of the row.
A password on a record will prevent updates or deletions to the record without a password. In the shortcode declaring an update or delete form, include a password attribute identifying the column password. The password input must equal the contents of the password field for the update or delete to take place.
Requires: 3.3 or higher
Compatible up to: 4.4.6
Last Updated: 11 months ago
Active Installs: 1,000+
0 of 6 support threads in the last two months have been marked resolved.
Got something to say? Need help?