From f7fd3ab4894a8c64ca5451c9450c1ba779ea65f0 Mon Sep 17 00:00:00 2001 From: Slim Amamou Date: Thu, 7 Feb 2008 11:24:20 +0100 Subject: [PATCH] j'ai merge le message d'erreur quand bazdig.db n'est pas ouvert en ecriture et j'ai corrige un bug qui affichait un message d'erreur quand les requetes ne sont pas sensees retourner un resultat comme insert, create ou autre --- bazdig/bazdig.css | 6 +++++ bazdig/console/index.php | 7 +++++- bazdig/sql/exec/index.php | 56 ++++++++++++++++++++++++++++------------------- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/bazdig/bazdig.css b/bazdig/bazdig.css index 6bc50ae..3450343 100644 --- a/bazdig/bazdig.css +++ b/bazdig/bazdig.css @@ -7,6 +7,12 @@ body { h3 { display: inline; } +#error { + background-color: yellow; + border: 2px solid red; + padding: 10px; + margin: 10px; +} #nav a { border: 1px outset silver ; padding: 5px 10px; diff --git a/bazdig/console/index.php b/bazdig/console/index.php index 259d8be..7364af6 100644 --- a/bazdig/console/index.php +++ b/bazdig/console/index.php @@ -18,7 +18,12 @@ - +getparam('db')->file; + if (!is_writable($bazdig_db)) { + echo '
WARNING your history database is not writeable. chmod 777 '. $bazdig->file .' && chmod 666 '. $bazdig_db .'
'; + } +?> diff --git a/bazdig/sql/exec/index.php b/bazdig/sql/exec/index.php index db5d28b..2f11107 100644 --- a/bazdig/sql/exec/index.php +++ b/bazdig/sql/exec/index.php @@ -23,15 +23,6 @@ SqlCode::set_db($history_db); $query = new SqlCode(stripslashes($_GET['q'])); - try { - $result = $query->exec($work_db); - } catch (Exception $e) { - die("ERREUR SQL:". $e->getMessage()); - } - - $query->save(); - $rows = $result->fetchAll(PDO::FETCH_ASSOC); - $columns = columnNames($rows[0]); ?> @@ -39,28 +30,47 @@ -"; - } else { + try { + $result = $query->exec($work_db); + } catch (Exception $e) { + die("
SQL ERROR ". $e->getMessage() ."
"); + } + + $query->save(); + + try { + $rows = $result->fetchAll(PDO::FETCH_ASSOC); + if (count($rows) < 1) { + die("
Empty
Empty
"); + } + } catch (Exception $e) { + die("
Empty
"); + } + $columns = columnNames($rows[0]); + + echo ""; + foreach ($columns as $c) { + echo ""; + } + echo ""; + foreach ($rows as $r) { echo ""; - foreach ($columns as $c) { - echo ""; + foreach ($r as $value) { + echo ""; } echo ""; - foreach ($rows as $r) { - echo ""; - foreach ($r as $value) { - echo ""; - } - echo ""; - } } + echo "
$c
$c$value
$value
"; ?> - -- 2.11.4.GIT