123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
-
-
-
- namespace Doctrine\DBAL\Portability;
-
- use Doctrine\Common\EventManager;
- use Doctrine\DBAL\Configuration;
- use Doctrine\DBAL\Driver;
-
- class Connection extends \Doctrine\DBAL\Connection
- {
- const PORTABILITY_ALL = 255;
- const PORTABILITY_NONE = 0;
- const PORTABILITY_RTRIM = 1;
- const PORTABILITY_EMPTY_TO_NULL = 4;
- const PORTABILITY_FIX_CASE = 8;
-
- const PORTABILITY_ORACLE = 9;
- const PORTABILITY_POSTGRESQL = 13;
- const PORTABILITY_SQLITE = 13;
- const PORTABILITY_OTHERVENDORS = 12;
-
-
-
- private $portability = self::PORTABILITY_NONE;
-
-
-
- private $case = \PDO::CASE_NATURAL;
-
- public function connect()
- {
- $ret = parent::connect();
- if ($ret) {
- $params = $this->getParams();
- if (isset($params['portability'])) {
- if ($this->_platform->getName() === "oracle") {
- $params['portability'] = $params['portability'] & self::PORTABILITY_ORACLE;
- } else if ($this->_platform->getName() === "postgresql") {
- $params['portability'] = $params['portability'] & self::PORTABILITY_POSTGRESQL;
- } else if ($this->_platform->getName() === "sqlite") {
- $params['portability'] = $params['portability'] & self::PORTABILITY_SQLITE;
- } else {
- $params['portability'] = $params['portability'] & self::PORTABILITY_OTHERVENDORS;
- }
- $this->portability = $params['portability'];
- }
- if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) {
- if ($this->_conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
-
- $this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
- } else {
- $this->case = ($params['fetch_case'] == \PDO::CASE_LOWER) ? CASE_LOWER : CASE_UPPER;
- }
- }
- }
- return $ret;
- }
-
- public function getPortability()
- {
- return $this->portability;
- }
-
- public function getFetchCase()
- {
- return $this->case;
- }
-
- public function executeQuery($query, array $params = array(), $types = array())
- {
- return new Statement(parent::executeQuery($query, $params, $types), $this);
- }
-
-
-
- public function prepare($statement)
- {
- return new Statement(parent::prepare($statement), $this);
- }
-
- public function query()
- {
- $this->connect();
-
- $stmt = call_user_func_array(array($this->_conn, 'query'), func_get_args());
- return new Statement($stmt, $this);
- }
- }
|