openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 2da7f25619dd1c6acc2dc093d08ad7624332da41
parent 8c8dbadf4eaba51613306f67bb66a5368c408113
Author: Jan Dankert <devnull@localhost>
Date:   Fri,  8 Dec 2017 23:42:39 +0100

Schickere Logmeldungen...

Diffstat:
modules/database/Sql.class.php | 31++++++++++++++++---------------
modules/database/driver/PDODriver.class.php | 2+-
2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/modules/database/Sql.class.php b/modules/database/Sql.class.php @@ -18,7 +18,7 @@ namespace database; use Logger; -use RuntimeException; +use LogicException; /** * SQL-Anweisung.<br> @@ -29,14 +29,14 @@ use RuntimeException; * Beispiel<br> * <pre> * // Neues Objekt erzeugen mit SQL-Anweisung - * $sql = $db->sql('SELECT * FROM xy WHERE id={uid} AND name={name}'); + * $stmt = $db->sql('SELECT * FROM xy WHERE id={uid} AND name={name}'); * * // Parameter f�llen - * $sql->setInt ('uid' ,1 ); - * $sql->setString('name','peter'); + * $stmt->setInt ('uid' ,1 ); + * $stmt->setString('name','peter'); * * // Fertige SQL-Anweisung verwenden - * $xy->execute( $sql->query ); + * $stmt->execute(); * </pre> * <br> * Ziele dieser Klasse sind:<br> @@ -70,13 +70,14 @@ class Sql * ) * </pre> */ - var $param = array(); - - - /** - * Erzeugt ein SQL-Objekt und analysiert die SQL-Anfrage. - */ - function __construct( $query = '' ) + public $param = array(); + + + /** + * Erzeugt ein SQL-Objekt und analysiert die SQL-Anfrage. + * @param string $query SQL-Query + */ + public function __construct( $query = '' ) { $this->parseSourceQuery( $query ); } @@ -85,9 +86,9 @@ class Sql /** * Die SQL-Anfrage wird auf Parameter untersucht. */ - function parseSourceQuery( $query ) + private function parseSourceQuery( $query ) { - Logger::debug( 'SQL-query: '.$query); + Logger::debug( "SQL-query:\n$query" ); while( true ) // Schleife wird solange durchlaufen, solange Parameter gefunden werden. { @@ -100,7 +101,7 @@ class Sql $nameParam = substr($query,$posKlLinks+1,$posKlRechts-$posKlLinks-1); // Name Parameter if ( isset($this->param[$nameParam ])) - throw new RuntimeException( 'Parameter '.$nameParam.' in Query mehrfach vorhanden.' ); + throw new LogicException( "The named parameter '$nameParam'' is used more than one time in the SQL query:\n$query" ); $this->param[$nameParam] = $posKlLinks; diff --git a/modules/database/driver/PDODriver.class.php b/modules/database/driver/PDODriver.class.php @@ -190,7 +190,7 @@ class PDODriver $this->stmt = $this->connection->prepare($query); if ( $this->stmt === false ) - throw new RuntimeException('Could not prepare statement: '.$query.' Cause: '.implode('/',$this->connection->errorInfo()) ); + throw new RuntimeException("Could not prepare statement:\n$query\nCause: ".implode(' / ',$this->connection->errorInfo()) ); }