Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium



Posted on 2009-04-28
Medium Priority
Last Modified: 2012-05-06

         I am using sql2wiki extension to retrieve data from sql table. Given a pagename "xyz", is it possible to use it as given in the page below such that the pagename matches the project name and yields result. The result i get is only the header of the table the records do not appear. What should I do.


<sql2wiki database="eqrunners">
 SELECT * from asset where project_id = (select project_id from projects where projects.project_name = "{{lc:{{PAGENAME}}}}");

Open in new window

Question by:eyeqube
  • 2
  • 2

Author Comment

ID: 24257701
other way to put it is....how may i take the pagename from wiki and pass it as a string to the sqlquery in sql2wiki extension

{{PAGENAME}} = "xyz"
LVL 49

Expert Comment

ID: 24268687
Have you tested with the subquery solely?

SELECT * FROM projects WHERE projects.project_name = "{{lc:{{PAGENAME}}}}"

Author Comment

ID: 24333424
yes. I gives the header of the fields. the data area is blank. Another question.
LVL 49

Accepted Solution

Roonaan earned 1500 total points
ID: 24348855
When I install and configure this locally, I see that the {{lc:{{PAGENAME}}}} just isn't parsed. Should I have more extension installed as well?

When I run it with a prefilled project name it works fine:

<sql2wiki database="eqrunners">
SELECT * from asset where project_id = (select project_id from projects where projects.project_name = "sql2wiki");

I wonder however if it is not safer to masquee sql2wiki, and build an additional wiki extension of your own that does not expose your sql like this:
<assetlist project="sql2wiki" />

Or when you want to use the current pagename, just allows for use without a project param.


Create a new file assetList.php and put it in your extensions folder. Paste in the below code, and then update your $localSettings.php to include
include "extensions/assetList.php";

This allows for wrapping sql2wiki and not exposing your queries inside the actual wiki test.
# Let mediawiki know we have a new extension
$wgExtensionFunctions[] = "wfAssetList";
# The wfAssetList makes the parser recognize <assetlist> tags
function wfAssetList() {
	GLOBAL $wgParser;
# This function is called when you put in an <assetlist>
# It detects if you use a project argument, or not
function wfAssetList_Hook($input, $argv, &$parser) {
	GLOBAL $wgTitle;
	if(isset($argv['project'])) {
		# We have a project=".." argument
		$project = $argv['project'];
	} else {
		# We don't have a project, so we use the current page name
		$project = $wgTitle->mTextform;
	# We now create our query, and let sql2wiki handle the rest.
	return renderSQL('SELECT * from asset where project_id = (select project_id from projects where projects.project_name = "'.$project.'")', array('database' => 'eqrunners'), $parser);

Open in new window


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question