diff options
Diffstat (limited to 'sqlbox')
-rw-r--r-- | sqlbox/view.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sqlbox/view.php b/sqlbox/view.php index 5c7c4e1..0c7c841 100644 --- a/sqlbox/view.php +++ b/sqlbox/view.php @@ -78,6 +78,8 @@ $form = new mod_sqlbox_form($PAGE->url->out(false)); $form->display(); $data = $form->get_data(); +$correct = true; + echo $OUTPUT->heading('SQL Query: '.$data->sqlbox_query); if (isset($data->sqlbox_query)) { $db = pg_connect("host=localhost dbname=sqlbox user=sqlbox password=foobar"); @@ -85,12 +87,17 @@ if (isset($data->sqlbox_query)) { error("Failed to connect to sqlbox db"); $table = db_get_table_from_query($db, $data->sqlbox_query); - $table_orig = db_get_table_from_query($db, $sqlbox->query); + if (strlen($sqlbox->query) > 0) { + $table_orig = db_get_table_from_query($db, $sqlbox->query); + if ($table->data != $table_orig->data || + $table->head != $table_orig->head) + $correct = false; + } pg_close($db); echo html_writer::table($table); - if ($table->data == $table_orig->data && $table->head == $table->head) + if ($correct) echo $OUTPUT->heading("Correct!"); else echo $OUTPUT->heading("Incorrect!"); |