Skip to content

Commit

Permalink
Merge pull request #5 from stefandoorn/master
Browse files Browse the repository at this point in the history
Allow $pdo to be nullable, to be able to extend class yourself + adjust VARCHAR into TEXT
  • Loading branch information
waza-ari committed Jul 12, 2015
2 parents e38ffbf + d3d1e0b commit 540c7b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/MySQLHandler/MySQLHandler.php
Expand Up @@ -24,7 +24,7 @@ class MySQLHandler extends AbstractProcessingHandler {
/**
* @var PDO pdo object of database connection
*/
private $pdo;
protected $pdo;

/**
* @var PDOStatement statement to insert a new record
Expand Down Expand Up @@ -54,10 +54,12 @@ class MySQLHandler extends AbstractProcessingHandler {
* @param bool|int $level Debug level which this handler should store
* @param bool $bubble
*/
public function __construct(PDO $pdo, $table, $additionalFields = array(), $level = Logger::DEBUG, $bubble = true) {
$this->pdo = $pdo;
$this->additionalFields = $additionalFields;
public function __construct(PDO $pdo = null, $table, $additionalFields = array(), $level = Logger::DEBUG, $bubble = true) {
if(!is_null($pdo)) {
$this->pdo = $pdo;
}
$this->table = $table;
$this->additionalFields = $additionalFields;
parent::__construct($level, $bubble);
}

Expand Down Expand Up @@ -89,7 +91,7 @@ private function initialize() {

//Add columns
if (!empty($addedColumns)) foreach ($addedColumns as $c) {
$this->pdo->exec('ALTER TABLE `'.$this->table.'` add `'.$c.'` VARCHAR(200) NULL DEFAULT NULL;');
$this->pdo->exec('ALTER TABLE `'.$this->table.'` add `'.$c.'` TEXT NULL DEFAULT NULL;');
}

//Prepare statement
Expand Down

0 comments on commit 540c7b9

Please sign in to comment.