You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Christian Grobmeier (JIRA)" <ji...@apache.org> on 2010/04/30 22:52:53 UTC

[jira] Updated: (LOG4PHP-115) Instanciate LoggerAppenderPDO "by hand" throw exception

     [ https://issues.apache.org/jira/browse/LOG4PHP-115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Grobmeier updated LOG4PHP-115:
----------------------------------------

    Fix Version/s: 2.1
                       (was: 2.0)

> Instanciate LoggerAppenderPDO "by hand" throw exception
> -------------------------------------------------------
>
>                 Key: LOG4PHP-115
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-115
>             Project: Log4php
>          Issue Type: Bug
>          Components: Code
>    Affects Versions: 2.0
>            Reporter: Vaceletm
>             Fix For: 2.1
>
>
> $logger = new LoggerAppenderPDO();
> $logger->setUser($sys_dbuser);
> $logger->setPassword($sys_dbpasswd);
> $logger->setDSN($dsn);
> $logger->setTable('forge_upgrade_log');
> $logger->setInsertSql('INSERT INTO forge_upgrade_log (timestamp, logger, level, message, thread, file, line) VALUES (?,?,?,?,?,?,?)');
> $logger->setInsertPattern('%d,%c,%p,%m,%t,%F,%L');
> $logger->activateOptions();
> Throw:
> PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in lib/log4php/appenders/LoggerAppenderPDO.php:161
> Patch:
> diff --git a/lib/log4php/appenders/LoggerAppenderPDO.php b/lib/log4php/appenders/LoggerAppenderPDO.php
> index 8fadd00..f9503a3 100644
> --- a/lib/log4php/appenders/LoggerAppenderPDO.php
> +++ b/lib/log4php/appenders/LoggerAppenderPDO.php
> @@ -126,6 +126,7 @@ class LoggerAppenderPDO extends LoggerAppender {
>              // test if log table exists
>              try {
>                  $result = $this->db->query('SELECT * FROM ' . $this->table . ' WHERE 1 = 0');
> +                $result->closeCursor();
>              } catch (PDOException $e) {
>                  // It could be something else but a "no such table" is the most likely
>                  $result = false;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.