Diff: Help/SqlResultPlugin

Differences between current version and predecessor to the previous major change of Help/SqlResultPlugin.

Other diffs: Previous Revision, Previous Author

Newer page: version 6 Last edited on 17 January 2022 3:00 by harold
Older page: version 5 Last edited on 9 September 2007 0:16 by harold Revert
@@ -1,27 +1,86 @@
-_short description_  
+The **~SqlResult** [[Help:WikiPlugin|plugin]] displays results of arbitrary SQL select statements in table form.  
  
-! Usage  
-<verbatim>  
- <?plugin SqlResult ?>  
-< /verbatim>  
+The database definition, the DSN, must be defined in the local file ##config /~SqlResult.ini##  
  
-! Arguments  
+A simple textfile with alias = dsn lines.  
  
-page _(default: current pagename)_:  
- The page to execute upon
+Optional template file to format the result and handle some logic
  
-! Example  
+Template vars: ##%%where%%##, ##%%sortby%%##, ##%%limit%%##  
  
-<verbatim>  
-<?plugin SqlResult ?>  
-</verbatim
+== Usage ==  
+{{{  
+<< SqlResult parameters  
+SELECT statement  
+>>  
+}}}  
  
-<?plugin SqlResult ?>  
+== Arguments ==  
  
-! Author  
-PhpWiki :ReiniUrban  
+{| class="bordered"  
+|-  
+ ! Argument  
+! Description  
+! Default value  
+|-  
+| **alias**  
+| DSN database specification  
+| false  
+|-  
+| **ordered**  
+| if to display as {{{<ol>}}} list : single col only without template  
+| false  
+|-  
+| **template**  
+| use a custom {{{<theme>/template.tmpl}}}  
+| false  
+|-  
+| **where**  
+| custom filter for the query  
+| false  
+|-  
+| **sortby**  
+| for paging  
+| false (no paging)  
+|-  
+| **limit**  
+| for paging  
+| 0,50 (only the first 50)  
+|}  
  
-! See Also  
+== Examples ==  
  
+{{{  
+<<SqlResult alias=mysql  
+ SELECT 'mysql password for string "xx":',  
+ PASSWORD('xx')  
+>>  
+  
+<<SqlResult alias=videos template=videos  
+ SELECT rating,title,date  
+ FROM video  
+ ORDER BY rating DESC  
+ LIMIT 5  
+>>  
+  
+<<SqlResult alias=imdb template=imdbmovies where||="Davies, Jeremy%"  
+SELECT m.title, m.date, n.name, c.role  
+ FROM movies as m, names as n, jobs as j, characters as c  
+ WHERE n.name LIKE "%%where%%"  
+ AND m.title_id = c.title_id  
+ AND n.name_id = c.name_id  
+ AND c.job_id = j.job_id  
+ AND j.description = 'Actor'  
+ ORDER BY m.date DESC  
+>>  
+}}}  
+  
+== Author ==  
+* [[Help:Reini Urban|Reini Urban]]  
+  
+== See Also ==  
+  
+<noinclude>  
 ---- 
-PhpWikiDocumentation Help:WikiPlugin  
+[[ PhpWikiDocumentation]] [[CategoryWikiPlugin]]  
+</noinclude>  

current version

The SqlResult plugin displays results of arbitrary SQL select statements in table form.

The database definition, the DSN, must be defined in the local file config/SqlResult.ini

A simple textfile with alias = dsn lines.

Optional template file to format the result and handle some logic.

Template vars: %%where%%, %%sortby%%, %%limit%%

Usage

<<SqlResult parameters
SELECT statement
>>

Arguments

Argument

Description

Default value

alias

DSN database specification

false

ordered

if to display as <ol> list: single col only without template

false

template

use a custom <theme>/template.tmpl

false

where

custom filter for the query

false

sortby

for paging

false (no paging)

limit

for paging

0,50 (only the first 50)

Examples

<<SqlResult alias=mysql
         SELECT 'mysql password for string "xx":',
                PASSWORD('xx')
>>

<<SqlResult alias=videos template=videos
         SELECT rating,title,date
                FROM video
                ORDER BY rating DESC
                LIMIT 5
>>

<<SqlResult alias=imdb template=imdbmovies where||="Davies, Jeremy%"
SELECT m.title, m.date, n.name, c.role
  FROM movies as m, names as n, jobs as j, characters as c
  WHERE n.name LIKE "%%where%%"
  AND m.title_id = c.title_id
  AND n.name_id = c.name_id
  AND c.job_id = j.job_id
  AND j.description = 'Actor'
  ORDER BY m.date DESC
>>

Author

See Also