4 Use like: <?plugin SqlQuery SELECT * FROM table2; ?>
5 What will yield a table dump of the selected result sets.
7 You must first enable this plugin - create a symlink into the
8 parent dir (it isn't found here in the off/ subdir).
11 $ewiki_plugins["mpi"]["sqlquery"] = "ewiki_mpi_sqlquery";
14 function ewiki_mpi_sqlquery($action, &$args, &$iii, &$s) {
16 #-- select PHP db funcs
17 if (function_exists("anydb_query")) {
18 $SQL_QUERY = "anydb_query";
19 $SQL_FETCH = "anydb_fetch_array";
22 $SQL_QUERY = "mysql_query";
23 $SQL_FETCH = "mysql_fetch_array";
27 if ($query = $args["_"]) {
30 if (!preg_match('/^\s*(SELECT|SHOW)\s+/i', $query, $uu)) {
31 return("SQL query rejected");
34 $result = $SQL_QUERY($query);
36 return("failed SQL query");
41 while($row = $SQL_FETCH($result)) {
42 foreach ($row as $i=>$d) {
51 $o .= '<table border="1" cellpadding="2" cellspacing="0" class="sql-query">';
52 $o .= '<tr><th>' . implode('</th><th>',array_keys($r[0])) . '</th></tr>'."\n";
54 foreach ($r as $row) {
56 $add = $alt ? ' class="alternate"' : '';
57 $o .= "<tr><td$add>" . implode("</td><td$add>",$row) . '</td></tr>'."\n";
64 return(mysql_error());