| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Licensed to CRATE Technology GmbH("Crate") under one or more contributor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * license agreements.  See the NOTICE file distributed with this work for | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * additional information regarding copyright ownership.  Crate licenses | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * this file to you under the Apache License, Version 2.0 (the "License"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * you may not use this file except in compliance with the License.  You may | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * obtain a copy of the License at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * http://www.apache.org/licenses/LICENSE-2.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Unless required by applicable law or agreed to in writing, software | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * License for the specific language governing permissions and limitations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * under the License. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * However, if you have executed another commercial license agreement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * with Crate these terms will supersede the license and you may use the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * software solely pursuant to the terms of the relevant commercial agreement. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | namespace Crate\DBAL\Driver\PDOCrate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Crate\DBAL\Platforms\CratePlatform1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Crate\DBAL\Platforms\CratePlatform; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Crate\DBAL\Platforms\CratePlatform4; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Crate\DBAL\Schema\CrateSchemaManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Doctrine\DBAL\Connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Doctrine\DBAL\Driver\API\ExceptionConverter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use Doctrine\DBAL\Platforms\AbstractPlatform; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use Doctrine\DBAL\VersionAwarePlatformDriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | class Driver implements \Doctrine\DBAL\Driver, VersionAwarePlatformDriver | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     const VERSION = '4.0.2'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     const NAME = 'crate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     private const VERSION_057 = '0.57.0'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     private const VERSION_4 = '4.0.0'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 12 |  |      * @return PDOConnection The database connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 12 |  |     public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return new PDOConnection($this->constructPdoDsn($params), $username, $password, $driverOptions); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * Constructs the Crate PDO DSN. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 12 |  |      * @return string The DSN. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 12 |  |     private function constructPdoDsn(array $params) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 12 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 12 |  |         $dsn = self::NAME . ':'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         if (isset($params['host']) && $params['host'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             $dsn .= $params['host']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 12 |  |             $dsn .= 'localhost'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 12 |  |         $dsn .= ':' . (isset($params['port']) ? $params['port'] : '4200'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         return $dsn; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     public function getDatabasePlatform() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         return new CratePlatform(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 4 |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 4 |  |     public function getSchemaManager(Connection $conn, AbstractPlatform $platform) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         // TODO: `$platform` added when upgrading to Doctrine3 - what to do with it? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         return new CrateSchemaManager($conn); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         return self::NAME; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 10 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 10 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     public function getDatabase(Connection $conn) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 238 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 238 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 2 |  |     public function createDatabasePlatformForVersion($version) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 236 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 2 |  |         if (version_compare($version, self::VERSION_057, "<")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             return new CratePlatform(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 234 |  |         } elseif (version_compare($version, self::VERSION_4, "<")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             return new CratePlatform1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             return new CratePlatform4(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 117 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     public function getExceptionConverter(): ExceptionConverter | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         // TODO: Implement getExceptionConverter() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         //       Added when upgrading to Doctrine3. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 123 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 124 |  |  |  | 
            
                        
This interface has been deprecated. The supplier of the interface has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.