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