From 6761036cbd97fbc7e7f4f260730c486c6b95a299 Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Wed, 15 Apr 2009 20:50:07 +0000 Subject: TDbLogRoute::createDbTable: add AUTO_INCREMENT attribute to log_id column if driver is mysql --- framework/Util/TLogRouter.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'framework/Util') diff --git a/framework/Util/TLogRouter.php b/framework/Util/TLogRouter.php index be6d620a..d37c6896 100644 --- a/framework/Util/TLogRouter.php +++ b/framework/Util/TLogRouter.php @@ -97,8 +97,8 @@ class TLogRouter extends TModule /** * Adds a TLogRoute instance to the log router. - * - * @param TLogRoute $route + * + * @param TLogRoute $route * @throws TInvalidDataTypeException if the route object is invalid */ public function addRoute($route) @@ -798,16 +798,23 @@ class TDbLogRoute extends TLogRoute /** * Creates the DB table for storing log messages. + * @todo create sequence for PostgreSQL */ protected function createDbTable() { + $db = $this->getDbConnection(); + $driver=$db->getDriverName(); + $autoidAttributes = ''; + if($driver==='mysql') + $autoidAttributes = 'AUTO_INCREMENT'; + $sql='CREATE TABLE '.$this->_logTable.' ( - log_id INTEGER NOT NULL PRIMARY KEY, + log_id INTEGER NOT NULL PRIMARY KEY ' . $autoidAttributes . ', level INTEGER, category VARCHAR(128), logtime VARCHAR(20), message VARCHAR(255))'; - $this->getDbConnection()->createCommand($sql)->execute(); + $db->createCommand($sql)->execute(); } /** -- cgit v1.2.3