Loading...
 
Skip to main content

Features / Usability


Passing variable to wiki page sql

posts: 13 US

I am trying to create a series of pages where the last page is a drill-down detail of the first page.

I have successfully created the initial page using a sql statement pulling data from a mysql table. I can create a link that calls a second "static" page with the drill down detail. I would rather create the drill down page on the fly from the first page.

see: http://pearson424.org/tiki/tiki-index.php?page=Test+2
with the drill down. This method requires that i make 200+ secondary pages. i feel i should be able to create the secondary pages on the fly as it's a very simple sql statement but i haven't figure out the correct syntax.

I found a page that says I should be able to do something like:
In tiki1.10, you have the possibility to pass global variables as the
username to the query
\{\SQL(db=>local, 0=>$user, 1=>5)}SELECT * from users_users WHERE login=? OR
userid=?\{SQL\}
where 0 is for the first ? and 1 for the second

thanks for any information

- pat

posts: 215

It looks like the substituting of variables for "?"s, in the SQL plugin, has not worked for a while. Maybe since Tiki 2? But the code to handle the substitution is still in the SQL plugin.

At some point, maybe in Tiki 3, the

Copy to clipboard
extract ($params,EXTR_SKIP);

statement was changed to require all the possible parameters to be defined in the params array. But the 0,1,...9 parameters were never added to the params array in the SQL plugin.

Since they are not defined in the params array, the "extract" ignores and never extracts them, and they are missing when it goes to use them to replace the "?"s, resulting in the "Missing db param" error message, even though they are present.

In a Tiki 12 version of the SQL plugin, I added the first number parameter, '0', to the params array, tested it, and it worked.

But, there is another problem which probably makes this parameter option not very useful, even if the 0-9 options are added to the params array.

Every time the code in a SQL plugin changes, the plugin will require approval before it will run.

The security fingerprint hash for the SQL plugin is generated from the plugin parameters and the SQL statement. Each time one of the numbered parameters changes, the SQL plugin would need to be validated again. If you used the 0=>$user, every time the user changed, the plugin would require validation.

You might consider writing your own plugin to generate your secondary pages.

Tom


posts: 13 US

Hmm.... Writing my own plugin ... I feel hamstrung in that I am so new at this. I have no issue writing the php nor with the mysql - but I worry about all the things I don't know ...

I can envision something that would "popout" the drill down information but am not sure how to start. I can write the php to pull the data and display the table - just not sure where to get the popout code (i'm worried i'll run amok with security issues rendering anything i do useless) is there an existing plugin that exhibits this display behavior so I could see how that part is coded?

or are you suggesting that I generate the 200+ static pages via a plugin?

tks

- p