DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:sqljson

SQL JSON Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Processing query to MySQL databases and display results as a JSON

Last updated on
2018-07-16
Provides
Syntax
Repository
Source

Similar to sqlquery

Tagged with database, json, mysql, query, sql

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: 2018-07-16 17:52 by Marie Mandrela