├── .gitignore ├── README.md ├── composer.json ├── composer.lock └── src └── Firebird ├── Connection.php ├── ConnectionFactory.php ├── DatabaseManager.php ├── FirebirdConnector.php ├── FirebirdServiceProvider.php ├── Model.php ├── Query ├── Builder.php ├── Grammars │ └── FirebirdGrammar.php └── Processors │ └── FirebirdProcessor.php └── Schema ├── Builder.php └── Grammars └── FirebirdGrammar.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | .DS_Store 3 | .*.sw? 4 | .idea 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-firebird 2 | 3 | # Please Note: 4 | 5 | This package has been abandoned by it's creator, when I created it there were no other decent laravel packages around and I needed it for one specific project. That project has since migrated and this driver was no longer necessary. 6 | My initial feeling was that the community would take it up and use my work as a base, which has happened if you look at the many forks that have been created. I trully wish I had more time to devote to this, as it was a passion project for a while. 7 | 8 | ## Recommended forks of this project include: 9 | 10 | * https://packagist.org/packages/harrygulliford/laravel-firebird 11 | * https://github.com/KKSzymanowski/laravel-6-firebird 12 | 13 | Thanks to all of you who have downloaded and found this package useful. 14 | 15 | Jacques. 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jacquestvanzuydam/laravel-firebird", 3 | "description": "A Firebird database package for the Laravel Framework", 4 | "license": "MIT", 5 | "version": "1.0.0.0", 6 | "authors": [ 7 | { 8 | "name": "Jacques van Zuydam", 9 | "email": "jtvanzuydam@gmail.com" 10 | } 11 | ], 12 | "minimum-stability": "dev", 13 | "require": { 14 | "php": ">=5.4.0", 15 | "illuminate/support": "5.0.*", 16 | "illuminate/container": "5.0.*", 17 | "illuminate/database": "5.0.*", 18 | "illuminate/events": "5.0.*" 19 | }, 20 | "autoload":{ 21 | "psr-0": { 22 | "Firebird\\": "src/" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "9f383b8b485f58599282e7a1acf882f0", 8 | "packages": [ 9 | { 10 | "name": "danielstjules/stringy", 11 | "version": "1.9.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/danielstjules/Stringy.git", 15 | "reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b", 20 | "reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-mbstring": "*", 25 | "php": ">=5.3.0" 26 | }, 27 | "require-dev": { 28 | "phpunit/phpunit": "~4.0" 29 | }, 30 | "type": "library", 31 | "autoload": { 32 | "psr-4": { 33 | "Stringy\\": "src/" 34 | }, 35 | "files": [ 36 | "src/Create.php" 37 | ] 38 | }, 39 | "notification-url": "https://packagist.org/downloads/", 40 | "license": [ 41 | "MIT" 42 | ], 43 | "authors": [ 44 | { 45 | "name": "Daniel St. Jules", 46 | "email": "danielst.jules@gmail.com", 47 | "homepage": "http://www.danielstjules.com" 48 | } 49 | ], 50 | "description": "A string manipulation library with multibyte support", 51 | "homepage": "https://github.com/danielstjules/Stringy", 52 | "keywords": [ 53 | "UTF", 54 | "helpers", 55 | "manipulation", 56 | "methods", 57 | "multibyte", 58 | "string", 59 | "utf-8", 60 | "utility", 61 | "utils" 62 | ], 63 | "time": "2015-02-10 06:19:18" 64 | }, 65 | { 66 | "name": "doctrine/inflector", 67 | "version": "dev-master", 68 | "source": { 69 | "type": "git", 70 | "url": "https://github.com/doctrine/inflector.git", 71 | "reference": "e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d" 72 | }, 73 | "dist": { 74 | "type": "zip", 75 | "url": "https://api.github.com/repos/doctrine/inflector/zipball/e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d", 76 | "reference": "e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d", 77 | "shasum": "" 78 | }, 79 | "require": { 80 | "php": ">=5.3.2" 81 | }, 82 | "require-dev": { 83 | "phpunit/phpunit": "4.*" 84 | }, 85 | "type": "library", 86 | "extra": { 87 | "branch-alias": { 88 | "dev-master": "1.0.x-dev" 89 | } 90 | }, 91 | "autoload": { 92 | "psr-0": { 93 | "Doctrine\\Common\\Inflector\\": "lib/" 94 | } 95 | }, 96 | "notification-url": "https://packagist.org/downloads/", 97 | "license": [ 98 | "MIT" 99 | ], 100 | "authors": [ 101 | { 102 | "name": "Roman Borschel", 103 | "email": "roman@code-factory.org" 104 | }, 105 | { 106 | "name": "Benjamin Eberlei", 107 | "email": "kontakt@beberlei.de" 108 | }, 109 | { 110 | "name": "Guilherme Blanco", 111 | "email": "guilhermeblanco@gmail.com" 112 | }, 113 | { 114 | "name": "Jonathan Wage", 115 | "email": "jonwage@gmail.com" 116 | }, 117 | { 118 | "name": "Johannes Schmitt", 119 | "email": "schmittjoh@gmail.com" 120 | } 121 | ], 122 | "description": "Common String Manipulations with regard to casing and singular/plural rules.", 123 | "homepage": "http://www.doctrine-project.org", 124 | "keywords": [ 125 | "inflection", 126 | "pluralize", 127 | "singularize", 128 | "string" 129 | ], 130 | "time": "2015-01-01 18:34:57" 131 | }, 132 | { 133 | "name": "illuminate/container", 134 | "version": "5.0.x-dev", 135 | "source": { 136 | "type": "git", 137 | "url": "https://github.com/illuminate/container.git", 138 | "reference": "a11c01c1d8b6941bd7ef2f104749ada5e34f146e" 139 | }, 140 | "dist": { 141 | "type": "zip", 142 | "url": "https://api.github.com/repos/illuminate/container/zipball/a11c01c1d8b6941bd7ef2f104749ada5e34f146e", 143 | "reference": "a11c01c1d8b6941bd7ef2f104749ada5e34f146e", 144 | "shasum": "" 145 | }, 146 | "require": { 147 | "illuminate/contracts": "5.0.*", 148 | "php": ">=5.4.0" 149 | }, 150 | "type": "library", 151 | "extra": { 152 | "branch-alias": { 153 | "dev-master": "5.0-dev" 154 | } 155 | }, 156 | "autoload": { 157 | "psr-4": { 158 | "Illuminate\\Container\\": "" 159 | } 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Taylor Otwell", 168 | "email": "taylorotwell@gmail.com" 169 | } 170 | ], 171 | "description": "The Illuminate Container package.", 172 | "homepage": "http://laravel.com", 173 | "time": "2015-03-25 17:06:14" 174 | }, 175 | { 176 | "name": "illuminate/contracts", 177 | "version": "5.0.x-dev", 178 | "source": { 179 | "type": "git", 180 | "url": "https://github.com/illuminate/contracts.git", 181 | "reference": "5cda7e58df704a224828491b90f6d86bb49c6b97" 182 | }, 183 | "dist": { 184 | "type": "zip", 185 | "url": "https://api.github.com/repos/illuminate/contracts/zipball/5cda7e58df704a224828491b90f6d86bb49c6b97", 186 | "reference": "5cda7e58df704a224828491b90f6d86bb49c6b97", 187 | "shasum": "" 188 | }, 189 | "require": { 190 | "php": ">=5.4.0" 191 | }, 192 | "type": "library", 193 | "extra": { 194 | "branch-alias": { 195 | "dev-master": "5.0-dev" 196 | } 197 | }, 198 | "autoload": { 199 | "psr-4": { 200 | "Illuminate\\Contracts\\": "" 201 | } 202 | }, 203 | "notification-url": "https://packagist.org/downloads/", 204 | "license": [ 205 | "MIT" 206 | ], 207 | "authors": [ 208 | { 209 | "name": "Taylor Otwell", 210 | "email": "taylorotwell@gmail.com" 211 | } 212 | ], 213 | "description": "The Illuminate Contracts package.", 214 | "homepage": "http://laravel.com", 215 | "time": "2015-03-24 23:11:34" 216 | }, 217 | { 218 | "name": "illuminate/database", 219 | "version": "5.0.x-dev", 220 | "source": { 221 | "type": "git", 222 | "url": "https://github.com/illuminate/database.git", 223 | "reference": "c0cf0be377b7a8e19f8942c9fb0992003562429b" 224 | }, 225 | "dist": { 226 | "type": "zip", 227 | "url": "https://api.github.com/repos/illuminate/database/zipball/c0cf0be377b7a8e19f8942c9fb0992003562429b", 228 | "reference": "c0cf0be377b7a8e19f8942c9fb0992003562429b", 229 | "shasum": "" 230 | }, 231 | "require": { 232 | "illuminate/container": "5.0.*", 233 | "illuminate/contracts": "5.0.*", 234 | "illuminate/support": "5.0.*", 235 | "nesbot/carbon": "~1.0", 236 | "php": ">=5.4.0" 237 | }, 238 | "suggest": { 239 | "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).", 240 | "illuminate/console": "Required to use the database commands (5.0.*).", 241 | "illuminate/events": "Required to use the observers with Eloquent (5.0.*).", 242 | "illuminate/filesystem": "Required to use the migrations (5.0.*)." 243 | }, 244 | "type": "library", 245 | "extra": { 246 | "branch-alias": { 247 | "dev-master": "5.0-dev" 248 | } 249 | }, 250 | "autoload": { 251 | "psr-4": { 252 | "Illuminate\\Database\\": "" 253 | } 254 | }, 255 | "notification-url": "https://packagist.org/downloads/", 256 | "license": [ 257 | "MIT" 258 | ], 259 | "authors": [ 260 | { 261 | "name": "Taylor Otwell", 262 | "email": "taylorotwell@gmail.com" 263 | } 264 | ], 265 | "description": "The Illuminate Database package.", 266 | "homepage": "http://laravel.com", 267 | "keywords": [ 268 | "database", 269 | "laravel", 270 | "orm", 271 | "sql" 272 | ], 273 | "time": "2015-04-08 01:42:10" 274 | }, 275 | { 276 | "name": "illuminate/events", 277 | "version": "5.0.x-dev", 278 | "source": { 279 | "type": "git", 280 | "url": "https://github.com/illuminate/events.git", 281 | "reference": "bf2f28157a5acba4df20980e8511850a6572f1f2" 282 | }, 283 | "dist": { 284 | "type": "zip", 285 | "url": "https://api.github.com/repos/illuminate/events/zipball/bf2f28157a5acba4df20980e8511850a6572f1f2", 286 | "reference": "bf2f28157a5acba4df20980e8511850a6572f1f2", 287 | "shasum": "" 288 | }, 289 | "require": { 290 | "illuminate/container": "5.0.*", 291 | "illuminate/contracts": "5.0.*", 292 | "illuminate/support": "5.0.*", 293 | "php": ">=5.4.0" 294 | }, 295 | "type": "library", 296 | "extra": { 297 | "branch-alias": { 298 | "dev-master": "5.0-dev" 299 | } 300 | }, 301 | "autoload": { 302 | "psr-4": { 303 | "Illuminate\\Events\\": "" 304 | } 305 | }, 306 | "notification-url": "https://packagist.org/downloads/", 307 | "license": [ 308 | "MIT" 309 | ], 310 | "authors": [ 311 | { 312 | "name": "Taylor Otwell", 313 | "email": "taylorotwell@gmail.com" 314 | } 315 | ], 316 | "description": "The Illuminate Events package.", 317 | "homepage": "http://laravel.com", 318 | "time": "2015-03-26 16:16:33" 319 | }, 320 | { 321 | "name": "illuminate/support", 322 | "version": "5.0.x-dev", 323 | "source": { 324 | "type": "git", 325 | "url": "https://github.com/illuminate/support.git", 326 | "reference": "0e069a45cdcb1a8a7d85f010f462f622f5b3c669" 327 | }, 328 | "dist": { 329 | "type": "zip", 330 | "url": "https://api.github.com/repos/illuminate/support/zipball/0e069a45cdcb1a8a7d85f010f462f622f5b3c669", 331 | "reference": "0e069a45cdcb1a8a7d85f010f462f622f5b3c669", 332 | "shasum": "" 333 | }, 334 | "require": { 335 | "danielstjules/stringy": "~1.8", 336 | "doctrine/inflector": "~1.0", 337 | "ext-mbstring": "*", 338 | "illuminate/contracts": "5.0.*", 339 | "php": ">=5.4.0" 340 | }, 341 | "suggest": { 342 | "jeremeamia/superclosure": "Required to be able to serialize closures (~2.0)." 343 | }, 344 | "type": "library", 345 | "extra": { 346 | "branch-alias": { 347 | "dev-master": "5.0-dev" 348 | } 349 | }, 350 | "autoload": { 351 | "psr-4": { 352 | "Illuminate\\Support\\": "" 353 | }, 354 | "files": [ 355 | "helpers.php" 356 | ] 357 | }, 358 | "notification-url": "https://packagist.org/downloads/", 359 | "license": [ 360 | "MIT" 361 | ], 362 | "authors": [ 363 | { 364 | "name": "Taylor Otwell", 365 | "email": "taylorotwell@gmail.com" 366 | } 367 | ], 368 | "description": "The Illuminate Support package.", 369 | "homepage": "http://laravel.com", 370 | "time": "2015-04-07 16:02:55" 371 | }, 372 | { 373 | "name": "nesbot/carbon", 374 | "version": "1.18.0", 375 | "source": { 376 | "type": "git", 377 | "url": "https://github.com/briannesbitt/Carbon.git", 378 | "reference": "99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36" 379 | }, 380 | "dist": { 381 | "type": "zip", 382 | "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36", 383 | "reference": "99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36", 384 | "shasum": "" 385 | }, 386 | "require": { 387 | "php": ">=5.3.0", 388 | "symfony/translation": "2.6.*" 389 | }, 390 | "require-dev": { 391 | "phpunit/phpunit": "~4.0" 392 | }, 393 | "type": "library", 394 | "autoload": { 395 | "psr-0": { 396 | "Carbon": "src" 397 | } 398 | }, 399 | "notification-url": "https://packagist.org/downloads/", 400 | "license": [ 401 | "MIT" 402 | ], 403 | "authors": [ 404 | { 405 | "name": "Brian Nesbitt", 406 | "email": "brian@nesbot.com", 407 | "homepage": "http://nesbot.com" 408 | } 409 | ], 410 | "description": "A simple API extension for DateTime.", 411 | "homepage": "http://carbon.nesbot.com", 412 | "keywords": [ 413 | "date", 414 | "datetime", 415 | "time" 416 | ], 417 | "time": "2015-03-26 03:05:57" 418 | }, 419 | { 420 | "name": "symfony/translation", 421 | "version": "2.6.x-dev", 422 | "target-dir": "Symfony/Component/Translation", 423 | "source": { 424 | "type": "git", 425 | "url": "https://github.com/symfony/Translation.git", 426 | "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af" 427 | }, 428 | "dist": { 429 | "type": "zip", 430 | "url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af", 431 | "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af", 432 | "shasum": "" 433 | }, 434 | "require": { 435 | "php": ">=5.3.3" 436 | }, 437 | "require-dev": { 438 | "psr/log": "~1.0", 439 | "symfony/config": "~2.3,>=2.3.12", 440 | "symfony/intl": "~2.3", 441 | "symfony/phpunit-bridge": "~2.7", 442 | "symfony/yaml": "~2.2" 443 | }, 444 | "suggest": { 445 | "psr/log": "To use logging capability in translator", 446 | "symfony/config": "", 447 | "symfony/yaml": "" 448 | }, 449 | "type": "library", 450 | "extra": { 451 | "branch-alias": { 452 | "dev-master": "2.6-dev" 453 | } 454 | }, 455 | "autoload": { 456 | "psr-0": { 457 | "Symfony\\Component\\Translation\\": "" 458 | } 459 | }, 460 | "notification-url": "https://packagist.org/downloads/", 461 | "license": [ 462 | "MIT" 463 | ], 464 | "authors": [ 465 | { 466 | "name": "Symfony Community", 467 | "homepage": "http://symfony.com/contributors" 468 | }, 469 | { 470 | "name": "Fabien Potencier", 471 | "email": "fabien@symfony.com" 472 | } 473 | ], 474 | "description": "Symfony Translation Component", 475 | "homepage": "http://symfony.com", 476 | "time": "2015-03-30 15:54:10" 477 | } 478 | ], 479 | "packages-dev": [], 480 | "aliases": [], 481 | "minimum-stability": "dev", 482 | "stability-flags": [], 483 | "prefer-stable": false, 484 | "prefer-lowest": false, 485 | "platform": { 486 | "php": ">=5.4.0" 487 | }, 488 | "platform-dev": [] 489 | } 490 | -------------------------------------------------------------------------------- /src/Firebird/Connection.php: -------------------------------------------------------------------------------- 1 | pdo = $pdo; 30 | 31 | $this->config = $config; 32 | 33 | // First we will setup the default properties. We keep track of the DB 34 | // name we are connected to since it is needed when some reflective 35 | // type commands are run such as checking whether a table exists. 36 | $this->database = $database; 37 | 38 | $this->tablePrefix = $tablePrefix; 39 | 40 | $this->config = $config; 41 | 42 | // The connection string 43 | $dsn = $this->getDsn($config); 44 | 45 | // Create the connection 46 | $this->connection = $this->createConnection($dsn, $config); 47 | 48 | // Set the database 49 | $this->db = $this->connection; 50 | 51 | // We need to initialize a query grammar and the query post processors 52 | // which are both very important parts of the database abstractions 53 | // so we initialize these to their default values while starting. 54 | $this->useDefaultQueryGrammar(); 55 | 56 | $this->useDefaultPostProcessor(); 57 | } 58 | /** 59 | * Return the DSN string from configuration 60 | * 61 | * @param array $config 62 | * @return string 63 | */ 64 | protected function getDsn(array $config) 65 | { 66 | // Check that the host and database are not empty 67 | if( ! empty($config['host']) && ! empty ($config['database']) ) 68 | { 69 | return 'firebird:dbname='.$config['host'].':'.$config['database'].';charset='.$config['charset']; 70 | } 71 | else 72 | { 73 | trigger_error( 'Cannot connect to Firebird Database, no host or path supplied' ); 74 | } 75 | } 76 | 77 | /** 78 | * Create the Firebird Connection 79 | * 80 | * @param string $dsn 81 | * @param array $config 82 | * @return PDO 83 | */ 84 | public function createConnection($dsn, array $config) 85 | { 86 | //Check the username and password 87 | if (!empty($config['username']) && !empty($config['password'])) 88 | { 89 | try { 90 | return new PDO($dsn, $config['username'], $config['password']); 91 | } catch (PDOException $e) { 92 | trigger_error($e->getMessage()); 93 | } 94 | } 95 | else 96 | { 97 | trigger_error('Cannot connect to Firebird Database, no username or password supplied'); 98 | } 99 | return null; 100 | } 101 | 102 | /** 103 | * Get the default query grammar instance 104 | * 105 | * @return Query\Grammars\FirebirdGrammar 106 | */ 107 | protected function getDefaultQueryGrammar() 108 | { 109 | return new Query\Grammars\FirebirdGrammar; 110 | } 111 | 112 | /** 113 | * Get the default post processor instance. 114 | * 115 | * @return Query\Processors\FirebirdProcessor 116 | */ 117 | protected function getDefaultPostProcessor() 118 | { 119 | return new Query\Processors\FirebirdProcessor; 120 | } 121 | 122 | /** 123 | * Get a schema builder instance for this connection. 124 | * @return Schema\Builder 125 | */ 126 | public function getSchemaBuilder() 127 | { 128 | if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } 129 | 130 | return new Schema\Builder($this); 131 | } 132 | 133 | /** 134 | * Get the default schema grammar instance. 135 | * 136 | * @return SchemaGrammar; 137 | */ 138 | protected function getDefaultSchemaGrammar() { 139 | return $this->withTablePrefix(new SchemaGrammar); 140 | } 141 | 142 | /** 143 | * Begin a fluent query against a database table. 144 | * 145 | * @param string $table 146 | * @return Firebird\Query\Builder 147 | */ 148 | public function table($table) 149 | { 150 | $processor = $this->getPostProcessor(); 151 | 152 | $query = new Query\Builder($this, $this->getQueryGrammar(), $processor); 153 | 154 | return $query->from($table); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/Firebird/ConnectionFactory.php: -------------------------------------------------------------------------------- 1 | container->bound($key = "db.connector.{$config['driver']}")) 39 | { 40 | return $this->container->make($key); 41 | } 42 | 43 | switch ($config['driver']) 44 | { 45 | case 'mysql': 46 | return new MySqlConnector; 47 | 48 | case 'pgsql': 49 | return new PostgresConnector; 50 | 51 | case 'sqlite': 52 | return new SQLiteConnector; 53 | 54 | case 'sqlsrv': 55 | return new SqlServerConnector; 56 | 57 | case 'firebird': 58 | return new FirebirdConnector; 59 | } 60 | 61 | throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]".__FILE__); 62 | } 63 | 64 | /** 65 | * Create a new connection instance. 66 | * 67 | * @param string $driver 68 | * @param \PDO $connection 69 | * @param string $database 70 | * @param string $prefix 71 | * @param array $config 72 | * @return \Illuminate\Database\Connection 73 | * 74 | * @throws \InvalidArgumentException 75 | */ 76 | protected function createConnection($driver, PDO $connection, $database, $prefix = '', array $config = array()) 77 | { 78 | if ($this->container->bound($key = "db.connection.{$driver}")) 79 | { 80 | return $this->container->make($key, array($connection, $database, $prefix, $config)); 81 | } 82 | 83 | switch ($driver) 84 | { 85 | case 'mysql': 86 | return new MySqlConnection($connection, $database, $prefix, $config); 87 | 88 | case 'pgsql': 89 | return new PostgresConnection($connection, $database, $prefix, $config); 90 | 91 | case 'sqlite': 92 | return new SQLiteConnection($connection, $database, $prefix, $config); 93 | 94 | case 'sqlsrv': 95 | return new SqlServerConnection($connection, $database, $prefix, $config); 96 | 97 | case 'firebird': 98 | return new FirebirdConnection($connection, $database, $prefix, $config); 99 | } 100 | 101 | throw new InvalidArgumentException("Unsupported driver [$driver]"); 102 | } 103 | } -------------------------------------------------------------------------------- /src/Firebird/DatabaseManager.php: -------------------------------------------------------------------------------- 1 | app = $app; 19 | $this->factory = $factory; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /src/Firebird/FirebirdConnector.php: -------------------------------------------------------------------------------- 1 | getOptions($config); 20 | 21 | $path = $config['database']; 22 | 23 | $charset = $config['charset']; 24 | 25 | $host = $config['host']; 26 | if ( empty($host)) 27 | { 28 | throw new InvalidArgumentException("Host not given, required."); 29 | } 30 | 31 | return $this->createConnection("firebird:dbname={$host}:{$path};charset={$charset}", $config, $options); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/Firebird/FirebirdServiceProvider.php: -------------------------------------------------------------------------------- 1 | app['db']); 18 | 19 | Model::setEventDispatcher($this->app['events']); 20 | } 21 | 22 | /** 23 | * Register the application services. 24 | * This is where the connection gets registered 25 | * 26 | * @return void 27 | */ 28 | public function register() 29 | { 30 | $this->registerQueueableEntityResolver(); 31 | 32 | // The connection factory is used to create the actual connection instances on 33 | // the database. We will inject the factory into the manager so that it may 34 | // make the connections while they are actually needed and not of before. 35 | $this->app->singleton('db.factory', function($app) 36 | { 37 | return new FirebirdConnectionFactory($app); 38 | }); 39 | 40 | // The database manager is used to resolve various connections, since multiple 41 | // connections might be managed. It also implements the connection resolver 42 | // interface which may be used by other components requiring connections. 43 | $this->app->singleton('db', function($app) 44 | { 45 | return new FirebirdDatabaseManager($app, $app['db.factory']); 46 | }); 47 | } 48 | 49 | /** 50 | * Register the queueable entity resolver implementation. 51 | * 52 | * @return void 53 | */ 54 | protected function registerQueueableEntityResolver() 55 | { 56 | $this->app->singleton('Illuminate\Contracts\Queue\EntityResolver', function() 57 | { 58 | return new Eloquent\QueueEntityResolver; 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Firebird/Model.php: -------------------------------------------------------------------------------- 1 | aggregate)) return; 40 | $select = ''; 41 | if (count($columns) > 0 && $query->limit == null && $query->aggregate == null) 42 | { 43 | $select = $query->distinct ? 'select distinct ' : 'select '; 44 | } 45 | 46 | return $select.$this->columnize($columns); 47 | } 48 | 49 | /** 50 | * Compile a select query into SQL. 51 | * 52 | * @param Illuminate\Database\Query\Builder 53 | * 54 | * @return string 55 | */ 56 | public function compileSelect(Builder $query) 57 | { 58 | if (is_null($query->columns)) $query->columns = array('*'); 59 | 60 | return trim($this->concatenate($this->compileComponents($query))); 61 | } 62 | 63 | /** 64 | * Compile an aggregated select clause. 65 | * 66 | * @param \Illuminate\Database\Query\Builder $query 67 | * @param array $aggregate 68 | * @return string 69 | */ 70 | protected function compileAggregate(Builder $query, $aggregate) 71 | { 72 | $column = $this->columnize($aggregate['columns']); 73 | 74 | // If the query has a "distinct" constraint and we're not asking for all columns 75 | // we need to prepend "distinct" onto the column name so that the query takes 76 | // it into account when it performs the aggregating operations on the data. 77 | if ($query->distinct && $column !== '*') 78 | { 79 | $column = 'distinct '.$column; 80 | } 81 | 82 | return 'select '.$aggregate['function'].'('.$column.') as aggregate'; 83 | } 84 | 85 | /** 86 | * Compile first instead of limit 87 | * 88 | * @param \Illuminate\Database\Query\Builder $query 89 | * @param int $limit 90 | * @return string 91 | */ 92 | protected function compileLimit(Builder $query, $limit) 93 | { 94 | return 'select first '.(int) $limit; 95 | } 96 | 97 | /** 98 | * Compile skip instead of offset 99 | * 100 | * @param \Illuminate\Database\Query\Builder $query 101 | * @param int $limit 102 | * @return string 103 | */ 104 | protected function compileOffset(Builder $query, $limit) 105 | { 106 | return 'skip '.(int) $limit; 107 | } 108 | 109 | } -------------------------------------------------------------------------------- /src/Firebird/Query/Processors/FirebirdProcessor.php: -------------------------------------------------------------------------------- 1 | getColumns($blueprint)); 45 | 46 | $sql = 'create table '.$this->wrapTable($blueprint)." ($columns)"; 47 | 48 | return $sql; 49 | } 50 | 51 | /** 52 | * Compile a drop table command. 53 | * 54 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 55 | * @param \Illuminate\Support\Fluent $command 56 | * @return string 57 | */ 58 | public function compileDrop(Blueprint $blueprint, Fluent $command) 59 | { 60 | return 'drop table '.$this->wrapTable($blueprint); 61 | } 62 | 63 | /** 64 | * Compile a primary key command. 65 | * 66 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 67 | * @param \Illuminate\Support\Fluent $command 68 | * @return string 69 | */ 70 | public function compilePrimary(Blueprint $blueprint, Fluent $command) 71 | { 72 | $command->name(null); 73 | 74 | return $this->compileKey($blueprint, $command, 'primary key'); 75 | } 76 | 77 | /** 78 | * Compile a unique key command. 79 | * 80 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 81 | * @param \Illuminate\Support\Fluent $command 82 | * @return string 83 | */ 84 | public function compileUnique(Blueprint $blueprint, Fluent $command) 85 | { 86 | $columns = $this->columnize($command->columns); 87 | 88 | $table = $this->wrapTable($blueprint); 89 | 90 | return "CREATE UNIQUE INDEX ".strtoupper(substr($command->index, 0, 31))." ON {$table} ($columns)"; 91 | } 92 | 93 | /** 94 | * Compile a plain index key command. 95 | * 96 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 97 | * @param \Illuminate\Support\Fluent $command 98 | * @return string 99 | */ 100 | public function compileIndex(Blueprint $blueprint, Fluent $command) 101 | { 102 | $columns = $this->columnize($command->columns); 103 | 104 | $table = $this->wrapTable($blueprint); 105 | 106 | return "CREATE INDEX ".strtoupper(substr($command->index, 0, 31))." ON {$table} ($columns)"; 107 | } 108 | 109 | /** 110 | * Compile an index creation command. 111 | * 112 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 113 | * @param \Illuminate\Support\Fluent $command 114 | * @param string $type 115 | * @return string 116 | */ 117 | protected function compileKey(Blueprint $blueprint, Fluent $command, $type) 118 | { 119 | $columns = $this->columnize($command->columns); 120 | 121 | $table = $this->wrapTable($blueprint); 122 | 123 | return "alter table {$table} add {$type} ($columns)"; 124 | } 125 | 126 | /** 127 | * Compile a foreign key command. 128 | * 129 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 130 | * @param \Illuminate\Support\Fluent $command 131 | * @return string 132 | */ 133 | public function compileForeign(Blueprint $blueprint, Fluent $command) 134 | { 135 | $table = $this->wrapTable($blueprint); 136 | 137 | $on = $this->wrapTable($command->on); 138 | 139 | // We need to prepare several of the elements of the foreign key definition 140 | // before we can create the SQL, such as wrapping the tables and convert 141 | // an array of columns to comma-delimited strings for the SQL queries. 142 | $columns = $this->columnize($command->columns); 143 | 144 | $onColumns = $this->columnize((array) $command->references); 145 | 146 | $sql = "alter table {$table} add constraint ".strtoupper(substr($command->index, 0, 31))." "; 147 | 148 | $sql .= "foreign key ({$columns}) references {$on} ({$onColumns})"; 149 | 150 | // Once we have the basic foreign key creation statement constructed we can 151 | // build out the syntax for what should happen on an update or delete of 152 | // the affected columns, which will get something like "cascade", etc. 153 | if ( ! is_null($command->onDelete)) 154 | { 155 | $sql .= " on delete {$command->onDelete}"; 156 | } 157 | 158 | if ( ! is_null($command->onUpdate)) 159 | { 160 | $sql .= " on update {$command->onUpdate}"; 161 | } 162 | 163 | return $sql; 164 | } 165 | 166 | /** 167 | * Compile a drop foreign key command. 168 | * 169 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 170 | * @param \Illuminate\Support\Fluent $command 171 | * @return string 172 | */ 173 | public function compileDropForeign(Blueprint $blueprint, Fluent $command) 174 | { 175 | $table = $this->wrapTable($blueprint); 176 | 177 | return "alter table {$table} drop constraint {$command->index}"; 178 | } 179 | 180 | /** 181 | * Get the SQL for a nullable column modifier. 182 | * 183 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 184 | * @param \Illuminate\Support\Fluent $column 185 | * @return string|null 186 | */ 187 | protected function modifyNullable(Blueprint $blueprint, Fluent $column) 188 | { 189 | return $column->nullable ? '' : ' not null'; 190 | } 191 | 192 | /** 193 | * Get the SQL for a default column modifier. 194 | * 195 | * @param \Illuminate\Database\Schema\Blueprint $blueprint 196 | * @param \Illuminate\Support\Fluent $column 197 | * @return string|null 198 | */ 199 | protected function modifyDefault(Blueprint $blueprint, Fluent $column) 200 | { 201 | if ( ! is_null($column->default)) 202 | { 203 | return " default ".$this->getDefaultValue($column->default); 204 | } 205 | } 206 | 207 | /** 208 | * Create the column definition for a char type. 209 | * 210 | * @param \Illuminate\Support\Fluent $column 211 | * @return string 212 | */ 213 | protected function typeChar(Fluent $column) 214 | { 215 | return 'VARCHAR'; 216 | } 217 | 218 | /** 219 | * Create the column definition for a string type. 220 | * 221 | * @param \Illuminate\Support\Fluent $column 222 | * @return string 223 | */ 224 | protected function typeString(Fluent $column) 225 | { 226 | return 'VARCHAR ('.$column->length.')'; 227 | } 228 | 229 | /** 230 | * Create the column definition for a text type. 231 | * 232 | * @param \Illuminate\Support\Fluent $column 233 | * @return string 234 | */ 235 | protected function typeText(Fluent $column) 236 | { 237 | return 'BLOB SUB_TYPE TEXT'; 238 | } 239 | 240 | /** 241 | * Create the column definition for a medium text type. 242 | * 243 | * @param \Illuminate\Support\Fluent $column 244 | * @return string 245 | */ 246 | protected function typeMediumText(Fluent $column) 247 | { 248 | return 'BLOB SUB_TYPE TEXT'; 249 | } 250 | 251 | /** 252 | * Create the column definition for a long text type. 253 | * 254 | * @param \Illuminate\Support\Fluent $column 255 | * @return string 256 | */ 257 | protected function typeLongText(Fluent $column) 258 | { 259 | return 'BLOB SUB_TYPE TEXT'; 260 | } 261 | 262 | /** 263 | * Create the column definition for a integer type. 264 | * 265 | * @param \Illuminate\Support\Fluent $column 266 | * @return string 267 | */ 268 | protected function typeInteger(Fluent $column) 269 | { 270 | return 'INTEGER'; 271 | } 272 | 273 | /** 274 | * Create the column definition for a big integer type. 275 | * 276 | * @param \Illuminate\Support\Fluent $column 277 | * @return string 278 | */ 279 | protected function typeBigInteger(Fluent $column) 280 | { 281 | return 'INTEGER'; 282 | } 283 | 284 | /** 285 | * Create the column definition for a medium integer type. 286 | * 287 | * @param \Illuminate\Support\Fluent $column 288 | * @return string 289 | */ 290 | protected function typeMediumInteger(Fluent $column) 291 | { 292 | return 'INTEGER'; 293 | } 294 | 295 | /** 296 | * Create the column definition for a tiny integer type. 297 | * 298 | * @param \Illuminate\Support\Fluent $column 299 | * @return string 300 | */ 301 | protected function typeTinyInteger(Fluent $column) 302 | { 303 | return 'SMALLINT'; 304 | } 305 | 306 | /** 307 | * Create the column definition for a small integer type. 308 | * 309 | * @param \Illuminate\Support\Fluent $column 310 | * @return string 311 | */ 312 | protected function typeSmallInteger(Fluent $column) 313 | { 314 | return 'SMALLINT'; 315 | } 316 | 317 | /** 318 | * Create the column definition for a float type. 319 | * 320 | * @param \Illuminate\Support\Fluent $column 321 | * @return string 322 | */ 323 | protected function typeFloat(Fluent $column) 324 | { 325 | return 'FLOAT'; 326 | } 327 | 328 | /** 329 | * Create the column definition for a double type. 330 | * 331 | * @param \Illuminate\Support\Fluent $column 332 | * @return string 333 | */ 334 | protected function typeDouble(Fluent $column) 335 | { 336 | return 'DOUBLE'; 337 | } 338 | 339 | /** 340 | * Create the column definition for a decimal type. 341 | * 342 | * @param \Illuminate\Support\Fluent $column 343 | * @return string 344 | */ 345 | protected function typeDecimal(Fluent $column) 346 | { 347 | return 'DECIMAL'; 348 | } 349 | 350 | /** 351 | * Create the column definition for a boolean type. 352 | * 353 | * @param \Illuminate\Support\Fluent $column 354 | * @return string 355 | */ 356 | protected function typeBoolean(Fluent $column) 357 | { 358 | return 'CHAR(1)'; 359 | } 360 | 361 | /** 362 | * Create the column definition for an enum type. 363 | * 364 | * @param \Illuminate\Support\Fluent $column 365 | * @return string 366 | */ 367 | protected function typeEnum(Fluent $column) 368 | { 369 | return 'VARCHAR'; 370 | } 371 | 372 | /** 373 | * Create the column definition for a json type. 374 | * 375 | * @param \Illuminate\Support\Fluent $column 376 | * @return string 377 | */ 378 | protected function typeJson(Fluent $column) 379 | { 380 | return 'BLOB SUB_TYPE 0'; 381 | } 382 | 383 | /** 384 | * Create the column definition for a date type. 385 | * 386 | * @param \Illuminate\Support\Fluent $column 387 | * @return string 388 | */ 389 | protected function typeDate(Fluent $column) 390 | { 391 | return 'TIMESTAMP'; 392 | } 393 | 394 | /** 395 | * Create the column definition for a date-time type. 396 | * 397 | * @param \Illuminate\Support\Fluent $column 398 | * @return string 399 | */ 400 | protected function typeDateTime(Fluent $column) 401 | { 402 | return 'TIMESTAMP'; 403 | } 404 | 405 | /** 406 | * Create the column definition for a time type. 407 | * 408 | * @param \Illuminate\Support\Fluent $column 409 | * @return string 410 | */ 411 | protected function typeTime(Fluent $column) 412 | { 413 | return 'TIMESTAMP'; 414 | } 415 | 416 | /** 417 | * Create the column definition for a timestamp type. 418 | * 419 | * @param \Illuminate\Support\Fluent $column 420 | * @return string 421 | */ 422 | protected function typeTimestamp(Fluent $column) 423 | { 424 | return 'TIMESTAMP'; 425 | } 426 | 427 | /** 428 | * Create the column definition for a binary type. 429 | * 430 | * @param \Illuminate\Support\Fluent $column 431 | * @return string 432 | */ 433 | protected function typeBinary(Fluent $column) 434 | { 435 | return 'BLOB SUB_TYPE 0'; 436 | } 437 | } 438 | --------------------------------------------------------------------------------