/** * @param ConnectionEventArgs $args * @return void */ public function postConnect(ConnectionEventArgs $args) { $params = $args->getConnection()->getParams(); $params += array('schemas' => null); $schemas = implode(',', (array) $params['schemas']); $sql = "SET search_path TO " . $schemas; $args->getConnection()->executeUpdate($sql); }
/** * After connecting, update this connection's database settings. * * Note: Doctrine expects this method to be called postConnect * * @param ConnectionEventArgs $args */ public function postConnect(ConnectionEventArgs $args) { $db = $args->getConnection(); $platform = $args->getDatabasePlatform()->getName(); if ($platform === 'sqlite') { $db->query('PRAGMA synchronous = OFF'); } elseif ($platform === 'mysql') { /** * @link https://groups.google.com/forum/?fromgroups=#!topic/silex-php/AR3lpouqsgs */ $db->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); // Set utf8 on names and connection, as all tables have this charset. We don't // also do 'SET CHARACTER SET utf8', because it will actually reset the // character_set_connection and collation_connection to @@character_set_database // and @@collation_database respectively. // see: http://stackoverflow.com/questions/1566602/is-set-character-set-utf8-necessary $db->executeQuery('SET NAMES utf8'); $db->executeQuery('SET CHARACTER_SET_CONNECTION = utf8'); } elseif ($platform === 'postgresql') { /** * @link https://github.com/doctrine/dbal/pull/828 */ $db->executeQuery("SET NAMES 'utf8'"); } }
/** * After connecting, update this connection's database settings. * * Note: Doctrine expects this method to be called postConnect * * @param ConnectionEventArgs $args */ public function postConnect(ConnectionEventArgs $args) { $db = $args->getConnection(); $platform = $args->getDatabasePlatform()->getName(); if ($platform === 'sqlite') { $db->query('PRAGMA synchronous = OFF'); } elseif ($platform === 'mysql') { /** * @link https://groups.google.com/forum/?fromgroups=#!topic/silex-php/AR3lpouqsgs */ $db->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); // Set utf8 on names and connection, as all tables have this charset. We don't // also do 'SET CHARACTER SET utf8', because it will actually reset the // character_set_connection and collation_connection to @@character_set_database // and @@collation_database respectively. // see: http://stackoverflow.com/questions/1566602/is-set-character-set-utf8-necessary $db->executeQuery('SET NAMES utf8'); $db->executeQuery('SET CHARACTER_SET_CONNECTION = utf8'); // Increase group_concat_max_len to 100000. By default, MySQL // sets this to a low value – 1024 – which causes issues with // certain Bolt content types – particularly repeaters – where // the outcome of a GROUP_CONCAT() query will be more than 1024 bytes. // See also: http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_group_concat_max_len $db->executeQuery('SET SESSION group_concat_max_len = 100000'); } elseif ($platform === 'postgresql') { /** * @link https://github.com/doctrine/dbal/pull/828 */ $db->executeQuery("SET NAMES 'utf8'"); } }
/** * @param ConnectionEventArgs $args * @return void */ public function postConnect(ConnectionEventArgs $args) { $collation = $this->_collation ? ' COLLATE ' . $this->_collation : ' '; $sql = 'SET NAMES ' . $this->_charset . $collation; $mb4 = str_replace(array('utf8 ', 'utf8_'), array('utf8mb4 ', 'utf8mb4_'), $sql); if ($mb4 !== $sql) { $sql .= '/*!50503,' . $mb4 . '*/'; } $args->getConnection()->executeUpdate($sql); }
/** * @param ConnectionEventArgs $args * @return void */ public function postConnect(ConnectionEventArgs $args) { if (count($this->_defaultSessionVars)) { array_change_key_case($this->_defaultSessionVars, \CASE_UPPER); $vars = array(); foreach ($this->_defaultSessionVars as $option => $value) { $vars[] = $option . " = '" . $value . "'"; } $sql = "ALTER SESSION SET " . implode(" ", $vars); $args->getConnection()->executeUpdate($sql); } }
public function postConnect(ConnectionEventArgs $args) { if ($this->postConnectCalled) { throw new \LogicException(sprintf('It looks like you have registered the %s to more than one connection. Please register one instance per connection.', get_class($this))); } $this->connection = $args->getConnection(); $this->schemaManager = new SchemaManager($this->connection); $this->postConnectCalled = true; if (!Type::hasType('geometry')) { Type::addType('geometry', 'Jsor\\Doctrine\\PostGIS\\Types\\GeometryType'); } if (!Type::hasType('geography')) { Type::addType('geography', 'Jsor\\Doctrine\\PostGIS\\Types\\GeographyType'); } }
public function postConnect(ConnectionEventArgs $args) { if ($this->postConnectCalled) { // Allows multiple postConnect calls for the same connection // instance. This is done by MasterSlaveConnection for example when // switching master/slave connections. if ($this->connection === $args->getConnection()) { return; } throw new \LogicException(sprintf('It looks like you have registered the %s to more than one connection. Please register one instance per connection.', get_class($this))); } $this->connection = $args->getConnection(); $this->schemaManager = new SchemaManager($this->connection); $this->postConnectCalled = true; if (!Type::hasType('geometry')) { Type::addType('geometry', 'Jsor\\Doctrine\\PostGIS\\Types\\GeometryType'); } if (!Type::hasType('geography')) { Type::addType('geography', 'Jsor\\Doctrine\\PostGIS\\Types\\GeographyType'); } if (!Type::hasType('raster')) { Type::addType('raster', 'Jsor\\Doctrine\\PostGIS\\Types\\RasterType'); } }
/** * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args * * @return void */ public function postConnect(ConnectionEventArgs $args) { $conn = $args->getConnection(); $conn->exec($this->sql); }
/** * @param ConnectionEventArgs $args * @return void */ public function postConnect(ConnectionEventArgs $args) { $sensitive = $this->caseSensitiveLike ? 'true' : 'false'; $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); }
/** * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args * * @return void */ public function postConnect(ConnectionEventArgs $args) { $collation = $this->_collation ? " COLLATE " . $this->_collation : ""; $args->getConnection()->executeUpdate("SET NAMES " . $this->_charset . $collation); }
/** * Doctrine defines its primary database abstraction information in what it * calls "Platform" classes (e.g. Doctrine\DBAL\Platforms\AbstractPlatform). * Each database Doctrine supports implements a Platform file * (e.g. OraclePlatform or MySqlPlatform). * * \Doctrine\DBAL\Platforms\OraclePlatform maps "DATE" fields to Doctrine's * own "datetime" type, which returns it as \DateTime. The problem is that * internally, Oracle DOES store time data as part of its "DATE" field (even * if it's not visible in its default representation DD-MON-RR == * "30-JUL-13"). Thus the Doctrine core devs thought it best to map the * database tyep "DATE" to Doctrine's "datetime" type. * * But if in your case you will never require time data with your DATE * fields this will change Oracle's "DATE" fields to be mapped * to Doctrine's "date" mapping type. This is the same behavior as almost * every other DBAL driver (except SQLServer, which does its own crazy * stuff). * * @param ConnectionEventArgs $args * @return void */ public function postConnect(ConnectionEventArgs $args) { $args->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('date', 'date'); }
/** * @param ConnectionEventArgs $args * * @throws \Doctrine\DBAL\DBALException */ public function postConnect(ConnectionEventArgs $args) { $args->getConnection()->executeQuery('SET SESSION group_concat_max_len = ' . (pow(2, 32) - 1) . '; SET SQL_BIG_SELECTS = 1'); }