1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Mysql; |
6
|
|
|
|
7
|
|
|
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder; |
8
|
|
|
use Yiisoft\Db\Schema\QuoterInterface; |
9
|
|
|
use Yiisoft\Db\Schema\SchemaInterface; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Implements MySQL, MariaDB specific query builder. |
13
|
|
|
*/ |
14
|
|
|
final class QueryBuilder extends AbstractQueryBuilder |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @psalm-var string[] $typeMap Mapping from abstract column types (keys) to physical column types (values). |
18
|
|
|
*/ |
19
|
|
|
protected array $typeMap = [ |
20
|
|
|
SchemaInterface::TYPE_PK => 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY', |
21
|
|
|
SchemaInterface::TYPE_UPK => 'int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', |
22
|
|
|
SchemaInterface::TYPE_BIGPK => 'bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY', |
23
|
|
|
SchemaInterface::TYPE_UBIGPK => 'bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', |
24
|
|
|
SchemaInterface::TYPE_CHAR => 'char(1)', |
25
|
|
|
SchemaInterface::TYPE_STRING => 'varchar(255)', |
26
|
|
|
SchemaInterface::TYPE_TEXT => 'text', |
27
|
|
|
SchemaInterface::TYPE_TINYINT => 'tinyint(3)', |
28
|
|
|
SchemaInterface::TYPE_SMALLINT => 'smallint(6)', |
29
|
|
|
SchemaInterface::TYPE_INTEGER => 'int(11)', |
30
|
|
|
SchemaInterface::TYPE_BIGINT => 'bigint(20)', |
31
|
|
|
SchemaInterface::TYPE_FLOAT => 'float', |
32
|
|
|
SchemaInterface::TYPE_DOUBLE => 'double', |
33
|
|
|
SchemaInterface::TYPE_DECIMAL => 'decimal(10,0)', |
34
|
|
|
SchemaInterface::TYPE_DATE => 'date', |
35
|
|
|
SchemaInterface::TYPE_BINARY => 'blob', |
36
|
|
|
SchemaInterface::TYPE_BOOLEAN => 'bit(1)', |
37
|
|
|
SchemaInterface::TYPE_MONEY => 'decimal(19,4)', |
38
|
|
|
SchemaInterface::TYPE_JSON => 'json', |
39
|
|
|
SchemaInterface::TYPE_DATETIME => 'datetime(0)', |
40
|
|
|
SchemaInterface::TYPE_TIMESTAMP => 'timestamp(0)', |
41
|
|
|
SchemaInterface::TYPE_TIME => 'time(0)', |
42
|
|
|
SchemaInterface::TYPE_UUID => 'binary(16)', |
43
|
|
|
SchemaInterface::TYPE_UUID_PK => 'binary(16) PRIMARY KEY', |
44
|
|
|
]; |
45
|
|
|
|
46
|
549 |
|
public function __construct( |
47
|
|
|
QuoterInterface $quoter, |
48
|
|
|
SchemaInterface $schema, |
49
|
|
|
) { |
50
|
549 |
|
$ddlBuilder = new DDLQueryBuilder($this, $quoter, $schema); |
51
|
549 |
|
$dmlBuilder = new DMLQueryBuilder($this, $quoter, $schema); |
52
|
549 |
|
$dqlBuilder = new DQLQueryBuilder($this, $quoter); |
53
|
549 |
|
parent::__construct($quoter, $schema, $ddlBuilder, $dmlBuilder, $dqlBuilder); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|