Talk:WikiDB/Syntax
From TestWiki
[edit] Calculated Fields
How difficult would it be to set up the 'repeat' tag so as to have full access to the power of an SQL SELECT query, including such things as calculated fields? I'm looking to put together a wiki that includes pages representing points of interest on a map, and I'd like each such page to include a data block that includes its coordinates and a repeat block that lists the five nearest points of interest. I know how to write an SQL query that would list all points of interest in ascending order of distance; but to do so, the query needs to include a calculated field (i.e., the distance). --69.233.0.75 23:21, 22 June 2008 (BST)
- Hmmm... I'm not sure. My main issue with that would be figuring out a way to do it without making a security hole. Could you give me some examples of the actual calculations - is it all just basic maths, or do you need access to built-in functions as well (e.g. trig functions, etc.) --HappyDog 08:54, 23 June 2008 (BST)
[edit] How to do queries?
... continuing my post from the Extension discussion/talk page, I found the criteria stuff buried in the "Repeat tag" documentation here now. I still don't know how to effectively use this extension. What I have is this "Type" table:
| id | type |
|---|---|
| 1 | Color |
| 2 | Fruit |
| 3 | Shoes |
and now I want to display the name in another data template, for
| name | type |
|---|---|
| Apple | 2 |
so that it would say:
- Apple (Fruit)
Can this be done, and how?
- Joins are not supported yet, I'm afraid, but they are in the pipeline. There may be a way to get round this via clever use of templates, but I have not tried experimenting with that, so I have no idea. --HappyDog 14:27, 27 November 2008 (GMT)
- I spent a good two days on trying to get this to work with templates instead, including things like the Parserfunctions extension and the ExpandAfter extension that was named here elsewhere. It is totally impossible to emulate this behavior. Even if you would create articles for every data row, with an includable wrapper template for it that would return the data you want through appropriate repeat tags, it doesn't work, because repeat statement from templates are not being parsed but instead just left as literal text in templates for the data tag. I've had a look at the source code and saw that there was already a lot of stuff inside regarding table joins, and I think that most of the things that pop up in the Bugs article on here are all variations of people trying to achieve the same thing, like my example above, so please: could we have this table join feature ASAP? Or just that templates which use other repeat tags are being correctly parsed when used for the data tag?