Changeset 4723 for trunk/lib/Doctrine
- Timestamp:
- 08/01/08 19:46:14 (5 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 9 added
- 49 modified
-
Adapter.php (modified) (1 diff)
-
Cache/Apc.php (modified) (2 diffs)
-
ClassMetadata.php (modified) (1 diff)
-
ClassMetadata/Factory.php (modified) (1 diff)
-
Connection.php (modified) (15 diffs)
-
Connection/Db2.php (modified) (1 diff)
-
Connection/Firebird.php (modified) (2 diffs)
-
Connection/Informix.php (modified) (1 diff)
-
Connection/Mock.php (modified) (2 diffs)
-
Connection/Mssql.php (modified) (2 diffs)
-
Connection/Mysql.php (modified) (3 diffs)
-
Connection/Oracle.php (modified) (3 diffs)
-
Connection/Pgsql.php (modified) (3 diffs)
-
Connection/Sqlite.php (modified) (1 diff)
-
DatabasePlatform (added)
-
DatabasePlatform.php (added)
-
DatabasePlatform/FirebirdPlatform.php (added)
-
DatabasePlatform/InformixPlatform.php (added)
-
DatabasePlatform/MsSqlPlatform.php (added)
-
DatabasePlatform/MySqlPlatform.php (added)
-
DatabasePlatform/OraclePlatform.php (added)
-
DatabasePlatform/PostgreSqlPlatform.php (added)
-
DatabasePlatform/SqlitePlatform.php (added)
-
DataDict/Firebird.php (modified) (1 diff)
-
DataDict/Informix.php (modified) (1 diff)
-
DataDict/Mssql.php (modified) (2 diffs)
-
DataDict/Mysql.php (modified) (1 diff)
-
DataDict/Oracle.php (modified) (1 diff)
-
DataDict/Pgsql.php (modified) (2 diffs)
-
DataDict/Sqlite.php (modified) (2 diffs)
-
Entity.php (modified) (3 diffs)
-
EntityManager.php (modified) (1 diff)
-
EventSubscriber.php (modified) (1 diff)
-
Export.php (modified) (2 diffs)
-
Expression/Firebird.php (modified) (2 diffs)
-
Expression/Informix.php (modified) (2 diffs)
-
Expression/Mssql.php (modified) (2 diffs)
-
Expression/Mysql.php (modified) (2 diffs)
-
Expression/Oracle.php (modified) (2 diffs)
-
Expression/Pgsql.php (modified) (2 diffs)
-
Expression/Sqlite.php (modified) (2 diffs)
-
Hydrator.php (modified) (1 diff)
-
Import.php (modified) (1 diff)
-
Null.php (modified) (1 diff)
-
Overloadable.php (modified) (1 diff)
-
Query/Production.php (modified) (2 diffs)
-
Query/Production/Atom.php (modified) (2 diffs)
-
Query/Production/IdentificationVariableDeclaration.php (modified) (1 diff)
-
Query/SqlBuilder.php (modified) (2 diffs)
-
Query/SqlExecutor/SingleTableDeleteUpdate.php (modified) (1 diff)
-
Transaction.php (modified) (20 diffs)
-
Transaction/Firebird.php (modified) (6 diffs)
-
Transaction/Informix.php (modified) (2 diffs)
-
Transaction/Mssql.php (modified) (4 diffs)
-
Transaction/Mysql.php (modified) (1 diff)
-
Transaction/Oracle.php (modified) (5 diffs)
-
Transaction/Pgsql.php (modified) (5 diffs)
-
Transaction/Sqlite.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/Adapter.php
r3882 r4723 31 31 * @version $Revision$ 32 32 * @author Konsta Vesterinen <kvesteri@cc.hut.fi> 33 * @todo Remove. 33 34 */ 34 35 class Doctrine_Adapter -
trunk/lib/Doctrine/Cache/Apc.php
r3931 r4723 20 20 */ 21 21 22 #namespace Doctrine::Common::Cache; 23 22 24 /** 23 25 * Doctrine_Cache_Apc … … 30 32 * @version $Revision$ 31 33 * @author Konsta Vesterinen <kvesteri@cc.hut.fi> 34 * @todo Rename to ApcCache 32 35 */ 33 36 class Doctrine_Cache_Apc extends Doctrine_Cache_Driver -
trunk/lib/Doctrine/ClassMetadata.php
r4718 r4723 1838 1838 $this->_generatorType = $type; 1839 1839 } 1840 1841 public function completeIdentifierMapping() 1842 { 1843 if ($this->getIdGeneratorType() == self::GENERATOR_TYPE_AUTO) { 1844 $platform = $this->_em->getConnection()->getDatabasePlatform(); 1845 if ($platform->prefersSequences()) { 1846 $this->_generatorType = self::GENERATOR_TYPE_SEQUENCE; 1847 } else if ($platform->prefersIdentityColumns()) { 1848 $this->_generatorType = self::GENERATOR_TYPE_IDENTITY; 1849 } else { 1850 $this->_generatorType = self::GENERATOR_TYPE_TABLE; 1851 } 1852 } 1853 } 1840 1854 1841 1855 /** -
trunk/lib/Doctrine/ClassMetadata/Factory.php
r4699 r4723 296 296 // the connection (or another) object. We just need to decide where to put 297 297 // the id generation types. 298 if ($class->getIdGeneratorType() == Doctrine_ClassMetadata::GENERATOR_TYPE_AUTO) { 299 switch (strtolower($this->_em->getConnection()->getDriverName())) { 300 case 'mysql': 301 // pick IDENTITY 302 $class->setIdGeneratorType(Doctrine_ClassMetadata::GENERATOR_TYPE_IDENTITY); 303 break; 304 case 'oracle': 305 //pick SEQUENCE 306 break; 307 case 'postgres': 308 //pick SEQUENCE 309 break; 310 case 'firebird': 311 //pick what? 312 break; 313 case 'mssql': 314 //pick what? 315 default: 316 throw new Doctrine_Exception("Encountered unknown database driver: " 317 . $this->_em->getConnection()->getDriverName()); 318 } 319 } 298 $class->completeIdentifierMapping(); 320 299 } 321 300 -
trunk/lib/Doctrine/Connection.php
r4718 r4723 23 23 24 24 #use Doctrine::Common::Configuration; 25 #use Doctrine::Common::EventManager; 26 #use Doctrine::DBAL::Exceptions::ConnectionException; 25 27 26 28 /** … … 41 43 * 42 44 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL 43 * @link www.phpdoctrine.org44 45 * @since 1.0 45 46 * @version $Revision$ … … 63 64 * 64 65 * Doctrine::DBAL could ship with a simple standard broker that uses a primitive 65 * round-robin approach to distribution. User can provide its own resolvers.66 * round-robin approach to distribution. User can provide its own brokers. 66 67 */ 67 abstract class Doctrine_Connection implements Countable68 abstract class Doctrine_Connection 68 69 { 69 70 /** … … 89 90 90 91 /** 91 * The attributes.92 *93 * @var array94 */95 protected $_attributes = array();96 97 /**98 92 * Name of the connection 99 93 * … … 112 106 * Whether or not a connection has been established. 113 107 * 114 * @var boolean $isConnected108 * @var boolean 115 109 */ 116 110 protected $_isConnected = false; … … 122 116 */ 123 117 protected $_quoteIdentifiers; 124 125 /**126 * The connection properties.127 *128 * @var array $properties129 */130 protected $properties = array(131 'sql_comments' => array(132 array('start' => '--', 'end' => "\n", 'escape' => false),133 array('start' => '/*', 'end' => '*/', 'escape' => false)),134 'identifier_quoting' => array('start' => '"', 'end' => '"','escape' => '"'),135 'string_quoting' => array('start' => "'", 'end' => "'", 'escape' => false,136 'escape_pattern' => false),137 'wildcards' => array('%', '_'),138 'varchar_max_length' => 255,139 );140 118 141 119 /** … … 174 152 * @var Doctrine::DBAL::Platforms::DatabasePlatform 175 153 */ 176 protected $_databasePlatform; 154 protected $_platform; 155 156 /** 157 * Enter description here... 158 * 159 * @var Doctrine::DBAL::Transactions::Transaction 160 */ 161 protected $_transaction; 177 162 178 163 /** … … 238 223 239 224 /** 240 * Enter description here... 241 * 242 * @param unknown_type $name 243 * @return unknown 244 * @todo Remove. Move properties to DatabasePlatform. 245 */ 246 public function getProperty($name) 247 { 248 if ( ! isset($this->properties[$name])) { 249 throw Doctrine_Connection_Exception::unknownProperty($name); 250 } 251 return $this->properties[$name]; 225 * Gets the DatabasePlatform for the connection. 226 * 227 * @return Doctrine::DBAL::Platforms::DatabasePlatform 228 */ 229 public function getDatabasePlatform() 230 { 231 throw new Doctrine_Connection_Exception("No DatabasePlatform available " 232 . "for connection " . get_class($this)); 252 233 } 253 234 … … 828 809 829 810 /** 830 * execute 811 * Executes an SQL SELECT query with the given parameters. 812 * 831 813 * @param string $query sql query 832 814 * @param array $params query parameters … … 861 843 862 844 /** 863 * exec 845 * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters. 846 * 864 847 * @param string $query sql query 865 848 * @param array $params query parameters 866 849 * 867 850 * @return PDOStatement|Doctrine_Adapter_Statement 851 * @todo Rename to executeUpdate(). 868 852 */ 869 853 public function exec($query, array $params = array()) { … … 892 876 } 893 877 } 894 895 /**896 *897 *898 * @return string899 * @todo Rather orm stuff900 */901 public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false)902 {903 return $query;904 }905 906 /**907 * Creates dbms specific LIMIT/OFFSET SQL for the subqueries that are used in the908 * context of the limit-subquery algorithm.909 *910 * @return string911 * @todo Rather ORM stuff912 */913 public function modifyLimitSubquery(Doctrine_Table $rootTable, $query, $limit = false,914 $offset = false, $isManip = false)915 {916 return $this->modifyLimitQuery($query, $limit, $offset, $isManip);917 }918 878 919 879 /** … … 946 906 * @todo Better name: getQueryCount() 947 907 */ 948 public function count()908 public function getQueryCount() 949 909 { 950 910 return $this->_queryCount; … … 1031 991 public function beginTransaction($savepoint = null) 1032 992 { 1033 return $this-> transaction->beginTransaction($savepoint);993 return $this->_transaction->beginTransaction($savepoint); 1034 994 } 1035 995 … … 1261 1221 } 1262 1222 } 1263 1264 public function getFormatter()1265 {1266 if ( ! $this->modules['formatter']) {1267 $this->modules['formatter'] = new Doctrine_Formatter($this);1268 }1269 return $this->modules['formatter'];1270 }1271 1223 1272 1224 public function getSequenceManager() … … 1278 1230 return $this->modules['sequence']; 1279 1231 } 1280 1281 /**1282 * Gets the default (preferred) Id generation strategy of the database platform.1283 *1284 * @todo Sure, the id generator types are more ORM functionality but they're1285 * still kind of dbal related. Maybe we need another set of classes (DatabasePlatform?)1286 * but im not so sure...1287 */1288 /*abstract*/ public function getDefaultIdGeneratorType()1289 {1290 1291 }1292 1232 } -
trunk/lib/Doctrine/Connection/Db2.php
r4374 r4723 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 Doctrine::autoload('Doctrine_Connection'); 21 22 22 /** 23 23 * Doctrine_Connection_Db2 -
trunk/lib/Doctrine/Connection/Firebird.php
r4523 r4723 46 46 * @param PDO $pdo database handle 47 47 */ 48 public function __construct( Doctrine_Manager $manager, $adapter)48 public function __construct(array $params) 49 49 { 50 51 $this->supported = array( 52 'sequences' => true, 53 'indexes' => true, 54 'affected_rows' => true, 55 'summary_functions' => true, 56 'order_by_text' => true, 57 'transactions' => true, 58 'savepoints' => true, 59 'current_id' => true, 60 'limit_queries' => 'emulated', 61 'LOBs' => true, 62 'replace' => 'emulated', 63 'sub_selects' => true, 64 'auto_increment' => true, 65 'primary_key' => true, 66 'result_introspection' => true, 67 'prepared_statements' => true, 68 'identifier_quoting' => false, 69 'pattern_escaping' => true 70 ); 71 // initialize all driver options 72 /** 73 $this->options['DBA_username'] = false; 74 $this->options['DBA_password'] = false; 75 $this->options['database_path'] = ''; 76 $this->options['database_extension'] = '.gdb'; 77 $this->options['server_version'] = ''; 78 */ 79 parent::__construct($manager, $adapter); 50 parent::__construct($params); 80 51 } 81 52 … … 93 64 } 94 65 95 /**96 * Adds an driver-specific LIMIT clause to the query97 *98 * @param string $query query to modify99 * @param integer $limit limit the number of rows100 * @param integer $offset start reading from given offset101 * @return string modified query102 */103 public function modifyLimitQuery($query, $limit, $offset)104 {105 if ( ! $offset) {106 $offset = 0;107 }108 if ($limit > 0) {109 $query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',110 "SELECT FIRST $limit SKIP $offset", $query);111 }112 return $query;113 }114 66 } -
trunk/lib/Doctrine/Connection/Informix.php
r3882 r4723 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 Doctrine::autoload('Doctrine_Connection'); 21 22 22 /** 23 23 * Doctrine_Connection_Mysql -
trunk/lib/Doctrine/Connection/Mock.php
r4628 r4723 33 33 * @link www.phpdoctrine.org 34 34 * @since 1.0 35 * @todo Remove. 35 36 */ 36 37 class Doctrine_Connection_Mock extends Doctrine_Connection_Common … … 49 50 public function __construct() 50 51 { 51 52 53 } 54 55 public function getDatabasePlatform() 56 { 57 return new Doctrine_DatabasePlatform_MySqlPlatform(); 52 58 } 53 59 -
trunk/lib/Doctrine/Connection/Mssql.php
r4718 r4723 45 45 * @param PDO $pdo database handle 46 46 */ 47 public function __construct( Doctrine_Manager $manager, $adapter)47 public function __construct(array $params) 48 48 { 49 // initialize all driver options 50 $this->supported = array( 51 'sequences' => 'emulated', 52 'indexes' => true, 53 'affected_rows' => true, 54 'transactions' => true, 55 'summary_functions' => true, 56 'order_by_text' => true, 57 'current_id' => 'emulated', 58 'limit_queries' => 'emulated', 59 'LOBs' => true, 60 'replace' => 'emulated', 61 'sub_selects' => true, 62 'auto_increment' => true, 63 'primary_key' => true, 64 'result_introspection' => true, 65 'prepared_statements' => 'emulated', 66 ); 67 68 parent::__construct($manager, $adapter); 49 parent::__construct($params); 69 50 } 70 51 … … 96 77 97 78 return '[' . str_replace(']', ']]', $identifier) . ']'; 98 }99 100 /**101 * Adds an adapter-specific LIMIT clause to the SELECT statement.102 * [ borrowed from Zend Framework ]103 *104 * @param string $query105 * @param mixed $limit106 * @param mixed $offset107 * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html108 * @return string109 */110 public function modifyLimitQuery($query, $limit, $offset, $isManip = false)111 {112 if ($limit > 0) {113 $count = intval($limit);114 115 $offset = intval($offset);116 if ($offset < 0) {117 throw new Doctrine_Connection_Exception("LIMIT argument offset=$offset is not valid");118 }119 120 $orderby = stristr($query, 'ORDER BY');121 if ($orderby !== false) {122 $sort = (stripos($orderby, 'desc') !== false) ? 'desc' : 'asc';123 $order = str_ireplace('ORDER BY', '', $orderby);124 $order = trim(preg_replace('/ASC|DESC/i', '', $order));125 }126 127 $query = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $query);128 129 $query = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $query . ') AS inner_tbl';130 if ($orderby !== false) {131 $query .= ' ORDER BY ' . $order . ' ';132 $query .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';133 }134 $query .= ') AS outer_tbl';135 if ($orderby !== false) {136 $query .= ' ORDER BY ' . $order . ' ' . $sort;137 }138 139 return $query;140 141 }142 143 return $query;144 79 } 145 80 -
trunk/lib/Doctrine/Connection/Mysql.php
r4628 r4723 25 25 * Doctrine_Connection_Mysql 26 26 * 27 * @package Doctrine28 * @subpackage Connection29 27 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL 30 28 * @author Konsta Vesterinen <kvesteri@cc.hut.fi> … … 51 49 public function __construct(array $params) 52 50 { 53 $this->supported = array(54 'sequences' => 'emulated',55 'indexes' => true,56 'affected_rows' => true,57 'transactions' => true,58 'savepoints' => false,59 'summary_functions' => true,60 'order_by_text' => true,61 'current_id' => 'emulated',62 'limit_queries' => true,63 'LOBs' => true,64 'replace' => true,65 'sub_selects' => true,66 'auto_increment' => true,67 'primary_key' => true,68 'result_introspection' => true,69 'prepared_statements' => 'emulated',70 'identifier_quoting' => true,71 'pattern_escaping' => true72 );73 74 $this->properties['string_quoting'] = array(75 'start' => "'",76 'end' => "'",77 'escape' => '\\',78 'escape_pattern' => '\\');79 80 $this->properties['identifier_quoting'] = array(81 'start' => '`',82 'end' => '`',83 'escape' => '`');84 85 $this->properties['sql_comments'] = array(86 array('start' => '-- ', 'end' => "\n", 'escape' => false),87 array('start' => '#', 'end' => "\n", 'escape' => false),88 array('start' => '/*', 'end' => '*/', 'escape' => false),89 );90 91 $this->properties['varchar_max_length'] = 255;92 93 51 parent::__construct($params); 94 52 } … … 234 192 return $dsn; 235 193 } 194 195 /** 196 * Gets the DatabasePlatform for the connection. 197 &