From 2b0486d9e92cdaaa62027501c149285feaf6ab2f Mon Sep 17 00:00:00 2001 From: rylon Date: Fri, 20 Dec 2013 09:54:31 +0100 Subject: [PATCH] fixed jsonresult html entities, connectionpg now logs notice if present --- db/connection/ConnectionPG.php | 13 ++++++++++--- log/result/JsonResult.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db/connection/ConnectionPG.php b/db/connection/ConnectionPG.php index 3b0130b..cc24637 100644 --- a/db/connection/ConnectionPG.php +++ b/db/connection/ConnectionPG.php @@ -18,21 +18,25 @@ class ConnectionPG extends ConnectionAbstr { public function __destruct(){} - public function prepare($stmtName, $stmt, $values){ + public function prepare($stmtName, $stmt, $values){ $result = pg_query_params($this->connection, 'SELECT name FROM pg_prepared_statements WHERE name = $1', array($stmtName)); //var_dump($stmt); //var_dump($values); if (pg_num_rows($result) == 0) { $result = \pg_prepare($this->connection, $stmtName, $stmt); + if(($info = \pg_last_notice($this->connection)) != ''){ + new \SYSTEM\LOG\INFO($info);} } if(!$result) throw new \SYSTEM\LOG\ERROR('Prepared Statement prepare fail: '. \pg_last_error($this->connection)); $result = \pg_execute($this->connection, $stmtName, $values); + if(($info = \pg_last_notice($this->connection)) != ''){ + new \SYSTEM\LOG\INFO($info);} if(!$result) - throw new \SYSTEM\LOG\ERROR("Could not execute prepare statement: ". \pg_last_error($this->connection)); + throw new \SYSTEM\LOG\ERROR("Could not execute prepare statement: ". \pg_last_error($this->connection)); return new ResultPostgres($result); } @@ -41,7 +45,10 @@ class ConnectionPG extends ConnectionAbstr { return pg_close($this->connection);} public function query($query){ - $result = pg_query($this->connection, $query); + $result = \pg_query($this->connection, $query); + if(($info = \pg_last_notice($this->connection)) != ''){ + new \SYSTEM\LOG\INFO($info);} + if(!$result){ throw new \SYSTEM\LOG\ERROR('Could not query Database. Check ur Query Syntax or required Rights: '.pg_last_error($this->connection));} diff --git a/log/result/JsonResult.php b/log/result/JsonResult.php index f40aefe..b007628 100644 --- a/log/result/JsonResult.php +++ b/log/result/JsonResult.php @@ -35,7 +35,7 @@ class JsonResult extends \SYSTEM\LOG\AbstractResult { $error = array(); $error['class'] = get_class($e); - $error['message'] = htmlentities($e->getMessage()); + $error['message'] = $e->getMessage(); $error['code'] = $e->getCode(); $error['file'] = $e->getFile(); $error['line'] = $e->getLine();