Skip to content

Commit

Permalink
clean working version
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmkjr committed Feb 27, 2016
1 parent 8c4be2c commit 90aef49
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/WordPressHandler/WordPressHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,24 @@ private function initialize()

$table_name = $this->prefix . $this->table;

$columns = "";
$fields = "";
$additionalFields = '';
foreach ($this->additionalFields as $f) {
$columns.= ", $f";
$additionalFields.=", $f TEXT NULL DEFAULT NULL";
$fields.= ", %s";
$additionalFields.=",\n$f TEXT NULL DEFAULT NULL";
}

$sql = "CREATE TABLE $table_name (
id INT(11) NOT NULL AUTO_INCREMENT,
channel VARCHAR(255),
level INTEGER,
message LONGTEXT,
time INTEGER UNSIGNED
$additionalFields
, PRIMARY KEY (id)
time INTEGER UNSIGNED$additionalFields,
PRIMARY KEY (id)
) $charset_collate;";


require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );

//Prepare statement

$this->statement = 'INSERT INTO `'.$this->prefix.$this->table.'` (channel, level, message, time'.$columns.')
VALUES (%s, %s, %s, %s'.$fields.')';

$this->initialized = true;
}
/**
Expand Down

0 comments on commit 90aef49

Please sign in to comment.