Skip to content

Commit

Permalink
Fixed a bug where the common header fields (channel, level, message a…
Browse files Browse the repository at this point in the history
…nd time) where removed due to wrong array intersection.

Further improved PDO compatibility, as a MySQL only statement was removed.

Closes #2
  • Loading branch information
waza-ari committed Feb 16, 2015
1 parent 94a51db commit e38ffbf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/MySQLHandler/MySQLHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ private function initialize() {
);

//Read out actual columns
$q = $this->pdo->prepare('DESCRIBE `'.$this->table.'`;');
$q->execute();
$actualFields = $q->fetchAll(PDO::FETCH_COLUMN);
$actualFields = array();
$rs = $this->pdo->query('SELECT * FROM `'.$this->table.'` LIMIT 0');
for ($i = 0; $i < $rs->columnCount(); $i++) {
$col = $rs->getColumnMeta($i);
$actualFields[] = $col['name'];
}

//Calculate changed entries
$removedColumns = array_diff($actualFields, $this->additionalFields);
$removedColumns = array_diff($actualFields, $this->additionalFields, array('channel', 'level', 'message', 'time'));
$addedColumns = array_diff($this->additionalFields, $actualFields);

//Remove columns
Expand Down Expand Up @@ -116,7 +119,6 @@ protected function write(array $record) {
}

//'context' contains the array

$contentArray = array_merge(array(
'channel' => $record['channel'],
'level' => $record['level'],
Expand Down

0 comments on commit e38ffbf

Please sign in to comment.