ZF2-562: Zend\Log\Write\Db creates non-existing database table columns

Issue Type: Bug Created: 2012-09-15T18:45:25.000+0000 Last Updated: 2012-10-08T20:14:29.000+0000 Status: Closed Fix version(s): Reporter: Martin_P (martin_p) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend\Log

  • zend\log
  • zend\log\writer\db

Related issues: Attachments:


Zend\Log\Writer\Db::eventIntoColumn creates new non-existing database table columns when $value is an array.

<pre class="highlight">
protected function eventIntoColumn(array $event)
    if (empty($event)) {
        return array();

    $data = array();
    foreach ($event as $name => $value) {
        if (is_array($value)) {
            foreach ($value as $key => $subvalue) {
                // New database table columns are being created here...
                $data[$name . $this->separator . $key] = $subvalue;
        } else {
            $data[$name] = $value;
    return $data;

This is highly illogical, because now this PHP-script decides what database table columns should exist. When an array with other keys is used all of a sudden the script generates new, other database columns and eventually make the entire script fail again because of a database error due to non-existing columns. The user should define the columns to be used and the script should never add non-existing database tabel columns on its own.

More logical would be to define a way to handle arrays with something like json_encode() or serialize(). The most important thing is that it does not break the logging like it does now, so when $value is an array it must always return a string, because that is the only type of variable you can write to a database table column.


Posted by Ralph Schindler (ralph) on 2012-10-08T20:14:29.000+0000

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit:

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.