From f1234ad5c967e2fc3f18662d32362cdfc5a93495 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 21 Nov 2012 10:49:44 +0100 Subject: wip --- sqlbox/view.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sqlbox/view.php') diff --git a/sqlbox/view.php b/sqlbox/view.php index ee30811..0f371b8 100644 --- a/sqlbox/view.php +++ b/sqlbox/view.php @@ -77,7 +77,24 @@ echo $OUTPUT->heading('Yay! It works!'); $form = new mod_sqlbox_form($PAGE->url->out(false)); $form->display(); -print_r($form->get_data()); +$data = $form->get_data(); + +echo $OUTPUT->heading('Query: '.$data->query); +if (isset($data->query)) { + $db = pg_connect("host=localhost dbname=sqlbox user=sqlbox password=foobar"); + if (!db) + error("Failed to connect to sqlbox db"); + + $result = pg_query($db, $data->query); + if (!$result) + error("Query failed!"); + + while($row=pg_fetch_row($result)){ + print_r($row); + echo "
\n"; + } +} + // Finish the page echo $OUTPUT->footer(); -- cgit