Plugin SQL | |
Use this wiki plugin to display the results of database queries. The plugin displays the results of the query in a formatted table. Or in other words: have you ever wished you could retrieve data that is actually in Tiki's (or some other) database, but not organized or displayed on-screen in the way you'd like? The SQL plugin allows you to do that. If you want to create a database, please see Trackers. |
Parameters | ||||||||||||||||||||||||||||||||||||||||
Query a MySQL database and display the results Introduced in Tiki 1. Required parameters are in bold .Go to the source code Preferences required: wikiplugin_sql
Note If you find this plugin isn't working with version 4.0, it can likely be fixed by the site administrator adding this line at the end of the db/local.php file: &api_tiki='adodb'; This issue is fixed in version 5.0 so that this adjustment isn't necessary. |
Troubleshooting | |
DSN | |
|
Permissions | |
|
A Word About Security | |
Use of the SQL plugin can pose a risk to the security of your Tiki site. If you use the SQL plugin on a Wiki page and give users permission to access the page, be sure to lock the page avoid users to see the source of that page. If you don't, users with appropriate permission could see the SQL code — and might decide to do a little "experimentation" to see what else they can pull out of the database! The SQL plugin can be used to pull in data from other databases, but this capability should be used only with caution. If you want to use the SQL plugin to access confidential or sensitive data, do so ONLY in the context of a well-secured intranet that is not accessible to external users. To enforce security any user viewing a page that uses the PLuginSQL will need the permission |
How to use the plugin | |
To use the SQL plugin, you must do the following:
Remember, though, that this page tells you how to insert the SQL statement in a Wiki page, but it won't work until you've defined a DSN. |
SQL | ||||||||||||||||||||||||||||||
This table represents some helpful information about the structure of an SQL "SELECT" statement. Detailed information regarding MySQL specific statements can be found on the MySQL documentation site. Much of the MySQL syntax is transferrable to other databases, but database specific documentation should be referenced to take full advantage of database nuances.
|
Examples | |
Note Though you may be accustomed to terminating SQL queries with punctuation such as a semi-colon (;), none is needed with the SQL statement within an SQL plugin. |
Basic Example | |
This code: Copy to clipboard
|
Raw Parameter Example | |
The Wizard
Copy to clipboard
|
Wiki Parse Flag Example | |
The "Wiki Parse Flag" parameter enables the plugin implementor to determine if the returned data should be Wiki parsed. An example for how this can be handy is if someone had a list of servers they were maintaining and were to select server information out of the database with the hostname bracketed in parens to make the hostname automatically become a link. In this case a location available to anyone with access is automatically created for keeping special notes as related to each server.
Without parsing Wizard
Copy to clipboard
With Parsing Wizard
Copy to clipboard
|
Delim Parameter Examples | |
The "Delim" parameter allows for the delimiter to be defined when "Raw" is used. Setting "Raw" is optional and assumed when a delimiter is defined. Straight Wiki Table The Wizard:
Copy to clipboard
Deluxe Wiki Table The below modification to the Wiki Code creates a Wiki Table with a summary statement at the bottom. This code: Copy to clipboard
|
CSV C&P | |
The This code: Copy to clipboard
Sorting and Selecting Data with the SQL PluginYou can use Secondary sort: Copy to clipboard
Copy to clipboard
Whoopee - a join: Copy to clipboard
Copy to clipboard
Global variables can also be used as the username to the query: Copy to clipboard
where 0 is for the first |
Related pages | |
|