|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Illuminate\Database; |
| 4 | + |
| 5 | +use Illuminate\Database\Query\Grammars\MariaDbGrammar as QueryGrammar; |
| 6 | +use Illuminate\Database\Query\Processors\MariaDbProcessor; |
| 7 | +use Illuminate\Database\Schema\Grammars\MariaDbGrammar as SchemaGrammar; |
| 8 | +use Illuminate\Database\Schema\MariaDbBuilder; |
| 9 | +use Illuminate\Database\Schema\MariaDbSchemaState; |
| 10 | +use Illuminate\Filesystem\Filesystem; |
| 11 | +use Illuminate\Support\Str; |
| 12 | + |
| 13 | +class MariaDbConnection extends MySqlConnection |
| 14 | +{ |
| 15 | + /** |
| 16 | + * Determine if the connected database is a MariaDB database. |
| 17 | + * |
| 18 | + * @return bool |
| 19 | + */ |
| 20 | + public function isMaria() |
| 21 | + { |
| 22 | + return true; |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Get the server version for the connection. |
| 27 | + * |
| 28 | + * @return string |
| 29 | + */ |
| 30 | + public function getServerVersion(): string |
| 31 | + { |
| 32 | + return Str::between(parent::getServerVersion(), '5.5.5-', '-MariaDB'); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Get the default query grammar instance. |
| 37 | + * |
| 38 | + * @return \Illuminate\Database\Query\Grammars\MariaDbGrammar |
| 39 | + */ |
| 40 | + protected function getDefaultQueryGrammar() |
| 41 | + { |
| 42 | + ($grammar = new QueryGrammar)->setConnection($this); |
| 43 | + |
| 44 | + return $this->withTablePrefix($grammar); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Get a schema builder instance for the connection. |
| 49 | + * |
| 50 | + * @return \Illuminate\Database\Schema\MariaDbBuilder |
| 51 | + */ |
| 52 | + public function getSchemaBuilder() |
| 53 | + { |
| 54 | + if (is_null($this->schemaGrammar)) { |
| 55 | + $this->useDefaultSchemaGrammar(); |
| 56 | + } |
| 57 | + |
| 58 | + return new MariaDbBuilder($this); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Get the default schema grammar instance. |
| 63 | + * |
| 64 | + * @return \Illuminate\Database\Schema\Grammars\MariaDbGrammar |
| 65 | + */ |
| 66 | + protected function getDefaultSchemaGrammar() |
| 67 | + { |
| 68 | + ($grammar = new SchemaGrammar)->setConnection($this); |
| 69 | + |
| 70 | + return $this->withTablePrefix($grammar); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Get the schema state for the connection. |
| 75 | + * |
| 76 | + * @param \Illuminate\Filesystem\Filesystem|null $files |
| 77 | + * @param callable|null $processFactory |
| 78 | + * @return \Illuminate\Database\Schema\MariaDbSchemaState |
| 79 | + */ |
| 80 | + public function getSchemaState(Filesystem $files = null, callable $processFactory = null) |
| 81 | + { |
| 82 | + return new MariaDbSchemaState($this, $files, $processFactory); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Get the default post processor instance. |
| 87 | + * |
| 88 | + * @return \Illuminate\Database\Query\Processors\MariaDbProcessor |
| 89 | + */ |
| 90 | + protected function getDefaultPostProcessor() |
| 91 | + { |
| 92 | + return new MariaDbProcessor; |
| 93 | + } |
| 94 | +} |
0 commit comments