WordPress.org

Ready to get started?Download WordPress

Plugin Directory

ABASE

MySQL interface. Create forms to insert, update and search. Embed tables or single values into pages. Foreign keys. Password records. Send email.

The ABASE shortcode accesses a MySQL database without having to code PHP. Over 30 optional attribute values specify whether a shortcode on a page is replaced with an HTML input form or an SQL query output. Forms to search, insert, update or delete records are easy to specify. Output can be a formatted value, table, or email. ABASE supports file uploads, images, record passwords and foreign keys.

Shortcode

The ABASE shortcode with a list of all the optional attributes is shown next. Each attribute is described in detail below.

[abase ack="" alink="" center="" cols="" columns="" database="" db="" echo="" elements="" emailbcc="" emailcc="" emailfrom="" emailorigin="" emailsubject="" emailto="" fields="" files="" form="" from="" group="" images="" insert="" left="" limit="" notable="" notitle="" or="" order="" password="" required="" right="" rlink="" rownum="" search="" select="" sql="" style="" table="" update="" where=""]

Within the quotes of each attribute can be a parameter value or a list of values separated by commas (,). Empty fields need not be specified. An unrecognized attribute is ignored. Using the shortcode with no (recognizable) attributes ([abase]) lists the database user, database, tables with record counts for the current database. Otherwise, either the sql, from, or table attribute should be used to specify part or all of a database operation, or an email sent, using at least an emailto attribute. The attribute names must be lower case.

ABASE shortcodes can also be of the form [abase ...]<content>[/abase]. In this form, <content> will be displayed above what [abase ...] produces. The shortcode name "abase" can be all lower-case or all upper-case but not mixed case. Each functions identically but are treated separately. Note that when including a closing shortcode, it must be case identical. <content> can include ABASE tags as long as the alternate case is used. Embedding shortcodes in content is useful when using ABASE to send emails from your website.

Databases

ABASE can connect to up to 3 databases, numbered 1, 2 and 3. (In Settings->ABASE for MySQL. Expand to full settings.) ABASE shortcodes default to using database 1. A db="1", db="2" or db="3" attribute in a shortcode will change the default database for this and 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, then not specify a db attribute in any of the remaining shortcodes on that page.

In addition to [abase] and [ABASE] shortcodes, two more are available. Shortcode [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.

Attributes

  • ack - ack=" ( <verbosity> ) ( , ) ( <url> ) ( , ) ( <color> )" - for acknowledging a record insert, update or search.
    • <verbosity>="1" or "2" or "3" or "4"
    • <url>=path-file of an update form for a record insert or update
    • <color>=HTML color of acknowledgement. If color is in all caps, acknowlegement will display in bold
  • alink - alink=" <column> ( , <url> ( , <append> ( , <target> ) ) )"
    • <column> - column name whose content will become a link to a <url> that is appended with the contents of column <append>.
    • <target> specifies the target window for the link (e.g., target="_blank" will open a new browser window.
  • center - center=" <column> ( , <column> )" specifies one or more table columns to center when displaying. Note: center="*" indicates all columns.
  • cols - cols=" <field_spec> ( , <field_spec> )" - Specifies the column names to be displayed as a table. Two or more records to be displayed are required. Designed to be used in conjunction with fields specification. See <field_spec> below under fields. Note: cols="*" indicates all columns.
  • columns - columns=" <field_spec> ( , <field_spec> )" - Specifies the columns to be displayed in a table. Zero or more records will be displayed. See <field_spec> below under fields. Note: columns="*" indicates all columns.
  • database - database="" Override default database specified in Settings. Sticky. (Specify once on page and override applies to remaining short codes until new db="" specification.)
  • db - db="" Change default database. Choose database 1, 2 or 3 as specified in Settings. Sticky. (Specify once on page and override applies to remaining short codes.)
  • echo - echo="<color>" will display (i.e., echo) the shortcode in the specified HTML <color> (e.g., echo="red").
  • elements - elements=" <column> ( , <column> )" specifies one or more fields in a form with form elements for either searching, adding to or updating the database.
  • emailbcc - emailbcc="" specify blind copy email address(es). Either a specific email address or a column name that contains an email address. emailto must be specified to send a email.
  • emailcc - emailcc="" specify copy email address(es). Either a specific email address or a column name that contains an email address. emailto must be specified to send a email.
  • emailfrom - emailfrom="" specify from email address. Either a specific email address or a column name that contains an email address. emailto must be specified to send a email.
  • emailorigin - emailorigin="" specifies origin information to add to the tail of every email. emailorigin="p" will display the page URL, emailorigin="r" will display the remote IP address of the browser, emailorigin="n" specifies nothing is to be displayed. When emailorigin="" is not specified then both the page URL and the remote IP address are displayed.
  • emailsubject - emailsubject="" specify email subject. emailto must be specified to send a email.
  • emailto - emailto="" specify email recipient. Either a specific email address or a column name that contains an email address. Only one email can be sent per shortcode execution.
  • fields - fields=" <field_spec> ( , <field_spec> )" - Specifies the column names to be displayed in record view. Record view is a two column table with the field names in the first column and the values in the second column.
    • Meta language: terms in parentheses are optional, vertical bar (|) - OR operator. (Exception - vertical bar (|) preceded <foreign_column>.)
    • <field_spec> ::= ( <column_title>^ ) <column_name> ( |<foreign_column> ) ( ! ( '( <element_type> <space> ) <element_style>' ) ) ( [>|>=|=|<=|<|!=] ( % ) <operand> ) ( % ) ( $ ( <button_value> ) )
    • <operand> ::= <surrogate> | <integer> | ' <constant> '
    • <column_title> = optionally precedes <column_name> using a carrot (^) character. It replaces <column_name> as column title in table view and field name in record view.
    • <column_name> = name of a column returned from the SELECT
    • <foreign_column> = follows <column_name> after a vertical-bar (|) character, is the name of the column in the foreign table containing the value to display instead of the foreign key contained in this column.
    • <button_value> = text displayed on the submit button.
    • <element_type> = form element type (e.g., button, checkbox, email, file, hidden, image, number, password, radio, reset, submit, tel, text, textarea, time or url)
    • <element_style> = can be either (a) one to three integer values separated with semicolons (;), (b) a style attribute for a form element or image, or (c) date and time format. A single integer value is interpreted as the width of the textbox in pixels. The default height is 18 pixels. A pair of integer values separated by a semicolon is interpreted as the width of the element in pixels followed by the height in pixels. A third integer value specifies the vertical alignment. Therefore, '250;25;-5' would be interpreted as style="width:250px;height:15px;vertical-align:-5px;" in the HTML element tag. Date and time formats are PHP defined, e.g., 'l, F j, Y g:ia e' would format Friday, July 19, 2013 8:33pm UTC at that time. Note that date and time inputs are translated to Unix time using the PHP strtotime function, accepting virtually any format for entering the date and time (e.g., "today" translates to today's date.)
    • <surrogate> = name of a form element to test against the current field value in a search.
    • <constant> = value field of a checkbox.
    • <integer> = digits consisting of 0-9.
    • <space> = blank space.
    Note: fields"*" indicates all fields.
  • files - files=" <column> ( , <column> )" specifies one or more columns that will contain URLs of uploaded files. The insert and update form elements are file selection boxes with browse buttons. Inserting or updating values in files fields involves file uploading to the File Upload Directory (specified in Settings). The uploaded file will be stored in the directory and the directory path and file name will be stored in the database table cell. A files column field type should be varchar(255).
  • form - form="( <form_type> , ) <tag_code> ( , <form_action> )" Beginning and/or end of HTML form.
    • tag_code="1" specifies this shortcode as an entire form. A <form ...> tag will appear at the beginning and a </form> tag will appear at the end.
    • tag_code="2" specifies this shortcode as the beginning of a form. A <form ...> tag will appear at the beginning.
    • tag_code="3" specifies this shortcode as the end of a form. A </form> tag will appear at the end.
    • tag_code="4" specifies this shortcode as an entire form to delete a record.
    • form_type="search" specifies this is a form to search the database.
    • form_type="insert" specifies this is a form to insert a new record into the database.
    • form_type="update" specifies this is a form to update a record in the database.
    • form_action - specifies a URL action for the form. If not specified, the current URL is used.
  • from - Specifies the table_references clause in the MySQL SELECT statement. Default is table specified.
  • group - Specifies the GROUP BY clause and can include a HAVING part.
  • images - images=" <column_spec> ( , <column_spec> )" specifies one or more columns that will contain URLs of uploaded images. Similar to files except when an images column is displayed, it is displayed as an HTML image tag with the cell content defining the image source.
    <column_spec> ::= ( <site_url>^ ) <column_name>, where <site_url> replaces the default site_url in the image "src" field.
    The insert and update form elements are file selection boxes with browse buttons. Inserting or updating values in images fields involves file uploading to the File Upload Directory (specified in Settings). The uploaded file will be stored in the directory and the directory path and file name will be stored in the database table cell. An images column field type should be varchar(255).
  • insert - insert="" (depreciated. Use form="insert".)
  • left - left=" <column> ( , <column> )" specifies one or more columns to left justify. Note: left="*" indicates all columns.
  • limit - Specifies a LIMIT clause.
  • notable - notable="1" will cause the table in a cols="" or columns="" specification to display without the beginning (<table>) or ending table tag (</table>).
  • notitle - notitle="1" will cause the table in a cols="" or columns="" specification to display without the column titles.
  • or - or=" <column_set> ( , <column_set> )" specifies sets of columns in a search form that are compated to the same operand in the WHERE clause.
    • <column_set> ::= <column> ( | <column> )
  • order - Specifies the ORDER BY clause.
  • password - password="" specify password field. Password entry and match is required to update or delete table record.
  • required - required=" <column> ( , <column> )" specifies one or more columns in an insert or update form that must have a filled in value or the submit will not be accepted. An error alert message will appear.
  • right - right=" <column> ( , <column> )" specifies one or more columns to right justify. Note: right="*" indicates all columns.
  • rlink - rlink=" <column> ( , <url> ( , <target> ) )" Record link. Link which specifies the primary index <name>=<value> pair in query string. Used to display a single record in the database.
    • <column> column that will be a link.
    • <url> if specified, the URL of the page to display the record. If not specified, link will be to the current page.
    • <target> specifies the target window for the link (e.g., target="_blank" will open a new browser window.
  • rownum - rownum="1" will add line numbers to the display tables.
  • search - search="" (depreciated. Use form="search".)
  • select - Specifies the select_expr clause in the MySQL SELECT statement. Default is * (all columns).
  • sql - Specifies a complete MySQL statement to be executed.
  • style - This will specify a style="" attribute for the table that encloses the shortcode display.
  • table - Specifies the database table to be searched or updated.
  • update - update="" (depreciated. Use form="update".)
  • where - Specifies the where_condition clause in the MySQL SELECT statement. If it begins with "AND " or "OR " it will be concatenated to (instead of overridding) any other where expression.

Displaying Fields

  • Use cols="", columns="" or fields=""
  • Use cols="<field_spec> ( , <field_spec> )" to display 2 or more records in table view.
  • Use columns="<field_spec> ( , <field_spec> )" to display any number of records in table view.
  • Use fields="<field_spec> ( , <field_spec> )" to display one record in record view.
  • cols="" and fields="" can be used in the same shortcode.

Requires: 3.3 or higher
Compatible up to: 3.9.1
Last Updated: 2014-5-14
Downloads: 4,361

Ratings

5 stars
5 out of 5 stars

Support

0 of 9 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,2,2 100,1,1 100,1,1
100,1,1
100,3,3 100,2,2
100,1,1
100,1,1
100,1,1