Skip to content

Commit

Permalink
Merge pull request #43 from mothership-gmbh/develop
Browse files Browse the repository at this point in the history
AbstractWorkflow compatibility with previous versions of PHP7
  • Loading branch information
Maurizio Brioschi authored Nov 2, 2016
2 parents 2850a08 + cc2c94e commit e14bf85
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract public function initialize();
*
* @return array
*/
public function fetchAll(string $sql, array $args = [], $pdoFetchType = \PDO::FETCH_ASSOC): array
public function fetchAll($sql, array $args = [], $pdoFetchType = \PDO::FETCH_ASSOC)
{
$pdo = \Mage::getSingleton('core/resource')->getConnection('core_read')->getConnection();
$stmt = $pdo->prepare($sql);
Expand All @@ -148,6 +148,7 @@ public function fetchAll(string $sql, array $args = [], $pdoFetchType = \PDO::FE
return $data;
}


/**
* Wrapper for doing query to the MySQL database.
*
Expand All @@ -159,7 +160,7 @@ public function fetchAll(string $sql, array $args = [], $pdoFetchType = \PDO::FE
*
* @return array
*/
public function fetch(string $sql, array $args = [], $pdoFetchType = \PDO::FETCH_ASSOC): array
public function fetch($sql, array $args = [], $pdoFetchType = \PDO::FETCH_ASSOC)
{
$pdo = \Mage::getSingleton('core/resource')->getConnection('core_read')->getConnection();
$stmt = $pdo->prepare($sql);
Expand All @@ -170,7 +171,11 @@ public function fetch(string $sql, array $args = [], $pdoFetchType = \PDO::FETCH
$stmt = null;
$pdo = null;

return $data;
if (false === empty($data)) {
return $data;
}

return [];
}

/**
Expand All @@ -181,7 +186,7 @@ public function fetch(string $sql, array $args = [], $pdoFetchType = \PDO::FETCH
*
* @return array the resultset
*/
public function exec(string $sql, array $args = [])
public function exec($sql, array $args = [])
{
$pdo = \Mage::getSingleton('core/resource')->getConnection('core_read')->getConnection();
$stmt = $pdo->prepare($sql);
Expand Down Expand Up @@ -347,6 +352,13 @@ protected function log(array $message)
{
$date = $this->date->format('d-m-Y H:i:s');

if (is_null($this->logFile) && isset($this->args['logFile'])) {
$this->logFile = $this->args['logFile'];
}
if (is_null($this->logFile)) {
return;
}

$message = array_merge([$date], $message);
error_log(implode("\t", $message) . "\n", 3, $this->logFile);
}
Expand Down

0 comments on commit e14bf85

Please sign in to comment.