MyPmWiki

Summary: Query a MySQL database server and display the results in a wiki page
Version: 2016-10-21
Prerequisites:
Status:
Maintainer:
Categories: Integration, Data, PHP55
Discussion: MyPmWiki-Talk

Goal

Query a MySQL database server and display the results in a wiki page.

Solution

A module called MyPmWiki that allows you to use SQL statements in a wiki page to query a MySQL database and display the results with a table.

Installation

Add this script to your "local" directory:

Include it in local.php with:

include_once("local/mypmwiki.php");

Set these variables in local.php:

$MyPmWiki_Hostname
hostname of the MySQL server (default is "localhost")
$MyPmWiki_Username
username to access the MySQL server (see caution below)
$MyPmWiki_Password
password to access the MySQL server (see caution below)
$MyPmWiki_DBName
name of the database to use
$MyPmWiki_TableFmt
formatting for the table tag (default is "border='1'")

The first and last variables are optional. All others must be set for MyPmWiki to work.

Caution: Unless you want to allow anyone to modify your database, make sure that you set up a user for MyPmWiki that has ONLY select privileges. Also, you must include the unencrypted password for this user in your local.php file. This user should have very limited rights to your MySQL server.

Usage

(:MyPmWiki SQL statement:)

Example

 (:MyPmWiki SELECT COUNT(*) as Number FROM devtable WHERE ACTION LIKE LOWER('%ipp%'):)

Working example:

Changelog

  • 2005-09-28
    • changed Markup from _begin to inline
  • 2016-10-21
    • update for PHP 5.5 compatibility

See also:

I've just contributed two new recipes that IMHO are safer and more functional than this one: SelectQuery and UpdateForm. Ben Stallings

Contributors

JamesDavis, fraz, Mike, Siegfried Seibert

Comments

See discussion at MyPmWiki-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.