Difference between revisions of "SQL.php"

From Organic Design wiki
 
(tidy up)
Line 1: Line 1:
 
<?
 
<?
 +
$db =& wfGetDB( DB_MASTER );
  
if ($event == 'data') {
+
# Get commands if admin
 
+
if ($GLOBALS['xwIsAdmin']) {
# Get an instance of wiki's DB object
+
if (xwGetProperty($properties, "xpath:$path/SQL", $sql)) {
$db =& wfGetDB( DB_MASTER );
+
xwMessage("Attempting to execute SQL \"$sql\"");
 
+
$result = $db->query($sql);
# Get commands if admin
+
# Render result rows as messages
if ($GLOBALS['xwIsAdmin']) {
+
while ($row = mysql_fetch_assoc($result)) {
if (xwGetProperty($properties, "xpath:$path/SQL", $sql)) {
+
$msg = '';
xwMessage("Attempting to execute SQL \"$sql\"");
+
foreach ($row as $k => $v) $msg .= "$k = $v, ";
$result = $db->query($sql);
+
xwMessage($msg,'red');
# Render result rows as messages
 
while ($row = mysql_fetch_assoc($result)) {
 
$msg = '';
 
foreach ($row as $k => $v) $msg .= "$k = $v, ";
 
xwMessage($msg,'red');
 
}
 
 
 
}
 
}
 
}
 
}
 
# Get filters from properties
 
if (!xwGetProperty($properties, "$path/max", $max)) $max = '';
 
if (!xwGetProperty($properties, "$path/filter", $filter)) $filter = '';
 
 
# Get filtered content from database
 
# $result = $db->query("SHOW TABLES;");
 
 
# Render rows into article
 
# while ($row = mysql_fetch_assoc($result)) {
 
# $article .= "\n*";
 
# foreach ($row as $k => $v) $article .= "$k=$v, ";
 
# }
 
 
}
 
}
 
elseif ($event == 'view') {
 
 
# Get reports from properties
 
if (!xwGetProperty($properties, "$path/report", $report)) $report = '';
 
 
}
 
 
 
 
?>
 
?>

Revision as of 01:27, 23 February 2006

<? $db =& wfGetDB( DB_MASTER );

  1. Get commands if admin

if ($GLOBALS['xwIsAdmin']) { if (xwGetProperty($properties, "xpath:$path/SQL", $sql)) { xwMessage("Attempting to execute SQL \"$sql\""); $result = $db->query($sql); # Render result rows as messages while ($row = mysql_fetch_assoc($result)) { $msg = ; foreach ($row as $k => $v) $msg .= "$k = $v, "; xwMessage($msg,'red'); } } } ?>