|
Cookbook /
AiSummary: Ai is another mysql data query using an original and efficient system of envelop and masks
Version: 4
Prerequisites: none
Status: functional, but experimental for security reasons maybe
Maintainer: François Elie (francois AT elie.org)
Questions answered by this recipeIs it possible simply to extract data from a database and display them as I want (table, list, etc...) ? Simply = without knowing an script language nor a template language. Only some SQL.
DescriptionAi is a markup to extract mysql data and define the manner they will be shown. A mechanism of embedded envelops (for table, for lines, for cells) and the use of mask for columns permit this. It is also very easy to rotate the table. PrincipleSee a demo of Ai If the demo is out of order, tell me please. InstallationPut version 4 of ai in cookbook directory of your PmWiki, (rename to ai.php) Put the line "include_once('cookbook/ai.php');" in your local/config.php file Set the variables to access the database: $ai_Hostname='<hostname>'; //default is 'localhost' $ai_Username='<username>'; //default is 'root'// $ai_Password='<password>'; // default is 'empty'// $ai_DBName='<database>'; Ai needs a file to read/write (the database structure) You have to tell to Ai his name and give permissions $ai_structure_file='/path/to/the/file'; It a good idea to put this file out of the zone accessible by the web (out of the DocumentRoot. For example, if the DocumentRoot is /var/www/html/, you can put the file in /var/www. Another solution is the put it in the cookbook directory of pmwiki (it has a .htaccess file to prevent direct access by the web). How to use itparameters are given line by line
queryQuery is standard SQL query. For minimal security reasons, only select, update and insert are allowed. orientationh (for horizontal) or v for (vertical). Default is v. global envelopSeparator between elements is comma. There is 4 element (then fourth is optional.
masks for columnsSeparator between elements is comma. To display the first column in italic, the second in bold, and the other in normal:
When then number of fields in the table is superior than the fields expected in all masks, the last mask is repeted to complete. (from v2) without parameter (note the word 'select' is added by Ai)(:ai [= select * from items =]:) with data rotate(:ai [= select * from items v =]:) envelop is given(:ai [= select * from items %s,<hr/><ul>%s</ul>,<li>%s</li> =]:) masks for columns are given(:ai [= select * from items <b>%s</b>,<i>%s</i>,<h1>%s</h1>,%s =]:) masks for several columns, for links or images etc...(:ai [= select * from items <b>%s</b>,<i>%s</i>,<a href="%s"><b>%s</b></a> =]:) if masks is not complete, completion is made by
|