cvs: pear /Log/Log sql.php
| From: | Jon Parise | Date: | Mon, 17 Feb 2003 21:17:24 +0000 |
| Subject: | cvs: pear /Log/Log sql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8920@lists.php.net to get a copy of this message | ||
jon Mon Feb 17 16:17:24 2003 EDT
Modified files:
/pear/Log/Log sql.php
Log:
On second thought, use CURRENT_TIME instead of generating our own TIMESTAMP
value using date(). CURRENT_TIME is apparently SQL:1999-compatible and
should yield more accurate timing values while being slighlty more efficient.
Also, improve the INSERT statement by providing the set of fields into
which the values will be inserted.
Index: pear/Log/Log/sql.php
diff -u pear/Log/Log/sql.php:1.16 pear/Log/Log/sql.php:1.17
--- pear/Log/Log/sql.php:1.16 Mon Feb 17 16:03:52 2003
+++ pear/Log/Log/sql.php Mon Feb 17 16:17:24 2003
@@ -1,5 +1,5 @@
<?php
-// $Id: sql.php,v 1.16 2003/02/17 21:03:52 jon Exp $
+// $Id: sql.php,v 1.17 2003/02/17 21:17:24 jon Exp $
// $Horde: horde/lib/Log/sql.php,v 1.12 2000/08/16 20:27:34 chuck Exp $
require_once 'DB.php';
@@ -21,7 +21,7 @@
* );
*
* @author Jon Parise <jon@php.net>
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
* @since Horde 1.3
* @package Log
*/
@@ -139,14 +139,12 @@
$this->open();
}
- $id = $this->_db->nextId('log_id');
- $now = date('Y-m-d H:i:s');
-
/* Build the SQL query for this log entry insertion. */
- $q = sprintf('insert into %s values(%d, %s, %s, %d, %s)',
- $this->_table, $id, $this->_db->quote($now),
- $this->_db->quote($this->_ident), $priority,
- $this->_db->quote($message));
+ $id = $this->_db->nextId('log_id');
+ $q = sprintf('insert into %s (id, logtime, ident, priority, message)' .
+ 'values(%d, CURRENT_TIMESTAMP, %s, %d, %s)',
+ $this->_table, $id, $this->_db->quote($this->_ident),
+ $priority, $this->_db->quote($message));
$result = $this->_db->query($q);
if (DB::isError($result)) {