Skip to content

Commit

Permalink
use a const for sql modes
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur authored and diosmosis committed Aug 21, 2015
1 parent 1d8f236 commit 1f393ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
class Db
{
const SQL_MODE = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE';

private static $connection = null;

private static $logQueries = true;
Expand Down
3 changes: 2 additions & 1 deletion core/Db/Adapter/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Exception;
use Piwik\Config;
use Piwik\Db;
use Piwik\Db\AdapterInterface;
use Piwik\Piwik;
use Zend_Config;
Expand Down Expand Up @@ -57,7 +58,7 @@ protected function _connect()

parent::_connect();

$this->_connection->query('SET sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE"');
$this->_connection->query('SET sql_mode = "' . Db::SQL_MODE . '"');
}

/**
Expand Down
3 changes: 2 additions & 1 deletion core/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PDO;
use PDOException;
use Piwik\Config;
use Piwik\Db;
use Piwik\Db\AdapterInterface;
use Piwik\Piwik;
use Zend_Config;
Expand Down Expand Up @@ -75,7 +76,7 @@ protected function _connect()
// MYSQL_ATTR_USE_BUFFERED_QUERY will use more memory when enabled
// $this->_connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);

$this->_connection->exec('SET sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE"');
$this->_connection->exec('SET sql_mode = "' . Db::SQL_MODE . '"');
}

/**
Expand Down

0 comments on commit 1f393ab

Please sign in to comment.