diff --git a/src/Mysql/MysqlDriver.php b/src/Mysql/MysqlDriver.php index 7a7c5c89..f359402e 100644 --- a/src/Mysql/MysqlDriver.php +++ b/src/Mysql/MysqlDriver.php @@ -127,6 +127,9 @@ public function __construct(array $options) $options['charset'] = $options['charset'] ?? 'utf8'; $options['sqlModes'] = isset($options['sqlModes']) ? (array) $options['sqlModes'] : $sqlModes; + // Use sqlBigSelects only if explicitly set. + $options['sqlBigSelects'] = isset($options['sqlBigSelects']) ? (bool) $options['sqlBigSelects'] : null; + $this->charset = $options['charset']; /* @@ -221,6 +224,12 @@ public function connect() $this->connection->query('SET @@SESSION.sql_mode = \'' . implode(',', $this->options['sqlModes']) . '\';'); } + // Set sql_big_selects if value provided in options + if ($this->options['sqlBigSelects'] !== null) + { + $this->connection->query('SET @@SESSION.sql_big_selects = ' . ($this->options['sqlBigSelects'] ? '1' : '0') . ';'); + } + $this->setOption(\PDO::ATTR_EMULATE_PREPARES, true); } diff --git a/src/Mysqli/MysqliDriver.php b/src/Mysqli/MysqliDriver.php index ee0fe407..01627b19 100644 --- a/src/Mysqli/MysqliDriver.php +++ b/src/Mysqli/MysqliDriver.php @@ -136,6 +136,9 @@ public function __construct(array $options) $options['ssl']['verify_server_cert'] = isset($options['ssl']['verify_server_cert']) ? $options['ssl']['verify_server_cert'] : null; } + // Use sqlBigSelects only if explicitly set. + $options['sqlBigSelects'] = isset($options['sqlBigSelects']) ? (bool) $options['sqlBigSelects'] : null; + // Finalize initialisation. parent::__construct($options); } @@ -307,6 +310,11 @@ public function connect() // And read the real sql mode to mitigate changes in mysql > 5.7.+ $this->options['sqlModes'] = explode(',', $this->setQuery('SELECT @@SESSION.sql_mode;')->loadResult()); + // Set sql_big_selects if value provided in options + if ($this->options['sqlBigSelects'] !== null) + { + $this->connection->query('SET @@SESSION.sql_big_selects = ' . ($this->options['sqlBigSelects'] ? '1' : '0') . ';'); + } // If auto-select is enabled select the given database. if ($this->options['select'] && !empty($this->options['database'])) { $this->select($this->options['database']);