plugin:sqljson
Table of Contents
SQL JSON Plugin
Compatible with DokuWiki
No compatibility info given!
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Similar to sqlquery
Description
This plugin processes a SQL query to a MySQL database and inserts the results as a JSON object. The object will be placed in a <script>
tag. The name of the variable holding the JSON object can be passed to the script.
The plugin is based on SQL Query Plugin, please donate to George Pirogov if you like it.
Syntax
Basic syntax:
<sqljson [objectname]>[query string]</sqljson>
query string
– SQL query to perform against the database.objectname
– name of the variable holding the JSON object, optional (default: “data”)
Examples
If the table “table” looks like this:
id | text | num |
---|---|---|
1 | f | 1665456 |
2 | m | 1838972 |
3 | 123 |
JSON is generated like this:
<sqljson test>select * from table;</sqljson>
The generated code will look like this:
<script> var test = [ { "id":"1", "text":"f", "num":"1665456" }, { "id":"2", "text":"m", "num":"1838972" }, { "id":"3", "text":" ", "num":"123" } ]; </script>
Configuration and Settings
The plugin can be configured via the Configuration Manager
Option | Description | Default value |
---|---|---|
Host | DNS name or IP address of MySQL server | localhost |
DB | MySQL database name | (empty) |
user | MySQL user name | (empty) |
password | MySQL password | (empty) |
Change Log
- 2018-07-16
- Initial release
Discussion, feature requests and bugs
plugin/sqljson.txt · Last modified: 2020-02-23 14:53 by Aleksandr