forked from hyperf/hyperf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MySqlConnection.php
executable file
·86 lines (77 loc) · 2.1 KB
/
MySqlConnection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Database;
use Hyperf\Database\DBAL\MySqlDriver;
use Hyperf\Database\Query\Grammars\MySqlGrammar as QueryGrammar;
use Hyperf\Database\Query\Processors\MySqlProcessor;
use Hyperf\Database\Schema\Grammars\MySqlGrammar as SchemaGrammar;
use Hyperf\Database\Schema\MySqlBuilder;
class MySqlConnection extends Connection
{
/**
* Get a schema builder instance for the connection.
*/
public function getSchemaBuilder(): MySqlBuilder
{
if (is_null($this->schemaGrammar)) {
$this->useDefaultSchemaGrammar();
}
return new MySqlBuilder($this);
}
/**
* Bind values to their parameters in the given statement.
*/
public function bindValues(\PDOStatement $statement, array $bindings): void
{
foreach ($bindings as $key => $value) {
$statement->bindValue(
is_string($key) ? $key : $key + 1,
$value
);
}
}
/**
* Get the default query grammar instance.
*
* @return \Hyperf\Database\Query\Grammars\MySqlGrammar
*/
protected function getDefaultQueryGrammar()
{
return $this->withTablePrefix(new QueryGrammar());
}
/**
* Get the default schema grammar instance.
*
* @return \Hyperf\Database\Schema\Grammars\MySqlGrammar
*/
protected function getDefaultSchemaGrammar()
{
return $this->withTablePrefix(new SchemaGrammar());
}
/**
* Get the default post processor instance.
*
* @return \Hyperf\Database\Query\Processors\MySqlProcessor
*/
protected function getDefaultPostProcessor()
{
return new MySqlProcessor();
}
/**
* Get the Doctrine DBAL driver.
*
* @return \Doctrine\DBAL\Driver\PDO\MySQL\Driver
*/
protected function getDoctrineDriver()
{
return new MySqlDriver();
}
}