MyPmWiki-Talk
This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.
Comments
Currently MyPmWiki uses a single database model. The administrator has control over which server and database will be used as well as table formatting. With appropriate markup, it would be possible to allow the author to select the server, user, and database as well as format the result table.
This is my first pmwiki addition. I adopted the script from pmwiki-1. There are a lot of expansion possible, it is only a hack!
This is a very nice extension, however the display look causes an error when the SQL query returns no result. philippe? January 11, 2005, at 16:18 AM
I've modified the code a bit to have different background color for odd rows
$resultStr = "<table $MyPmWiki_TableFmt style=\"border-collapse: collapse;\"><tr>"; for ($i = 0; $i < mysql_num_fields($result); $i++) { $resultStr .= "<th>".mysql_field_name($result, $i)."</th>"; } $resultStr .= "</tr>"; $x = 1; while($row = mysql_fetch_row($result)) { $resultStr .= "<tr>"; if($x%2): $color = "#dee"; else: $color = "#eed"; endif; foreach ($row as $field) { $resultStr .= "<td style=\"background-color: ".$color."\">$field</td>"; } $x++; $resultStr .= "</tr>"; } $resultStr .= "</table>"; }
(luca marletta)
I added variables in Markup that override defaults in local/config.php. I.e., if these variables are not specified in the directive they will default to the variables defined in local/config.php for MyPmWiki. This allows you to use multiple databases and table formats in one pmwiki site. The variables are the same as the ones above but in lowercase and without the MyPmWiki part so they are: hostname username password dbname tablefmt sql (new variable, required due to the need to quote the sql string. This may be not strictly necessary (one could join the array of all strings not in other variable assignments), but in my opinion it is not a burden to use the new variable.) Example usage would be: (:MyPmWiki hostname="localhost" dbname="pmwiki" sql="select * from mytable where name='wiki';":)
The code is hereΔ. - Paul Eden
18 Nov 2005
This is a helpful script.
- I think that the two instances of "local.php" above should read "local/config.php".
- Here is the table format I use. It helps make the table more readable.
$MyPmWiki_TableFmt = 'border="1" cellpadding="6" frame="box" rules="rows" style="border-collapse: collapse; font-family:Times New Roman; font-size:10pt"';
- More information about the MySQL SELECT statement is available here.
-- Mike
Just needed, because it is only on a local PC, it works fine, after upgrading to mysqli and taking care of the forbidden /e swich in regexps. ;-)
--PKHG