Uploaded image for project: 'Log4php'
  1. Log4php
  2. LOG4PHP-115

Instanciate LoggerAppenderPDO "by hand" throw exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.1.0
    • Code
    • None

    Description

      $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;

      Attachments

        Activity

          People

            Unassigned Unassigned
            vaceletm Vaceletm
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: