-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
QueryBuilder.php
62 lines (57 loc) · 2.23 KB
/
QueryBuilder.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
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Mysql;
use Yiisoft\Db\Connection\ServerInfoInterface;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\Mysql\Column\ColumnDefinitionBuilder;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;
/**
* Implements MySQL, MariaDB specific query builder.
*/
final class QueryBuilder extends AbstractQueryBuilder
{
/**
* @psalm-var string[] $typeMap Mapping from abstract column types (keys) to physical column types (values).
*/
protected array $typeMap = [
PseudoType::PK => 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY',
PseudoType::UPK => 'int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
PseudoType::BIGPK => 'bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY',
PseudoType::UBIGPK => 'bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
ColumnType::CHAR => 'char(1)',
ColumnType::STRING => 'varchar(255)',
ColumnType::TEXT => 'text',
ColumnType::TINYINT => 'tinyint(3)',
ColumnType::SMALLINT => 'smallint(6)',
ColumnType::INTEGER => 'int(11)',
ColumnType::BIGINT => 'bigint(20)',
ColumnType::FLOAT => 'float',
ColumnType::DOUBLE => 'double',
ColumnType::DECIMAL => 'decimal(10,0)',
ColumnType::DATE => 'date',
ColumnType::BINARY => 'blob',
ColumnType::BOOLEAN => 'bit(1)',
ColumnType::MONEY => 'decimal(19,4)',
ColumnType::JSON => 'json',
ColumnType::DATETIME => 'datetime(0)',
ColumnType::TIMESTAMP => 'timestamp(0)',
ColumnType::TIME => 'time(0)',
ColumnType::UUID => 'binary(16)',
PseudoType::UUID_PK => 'binary(16) PRIMARY KEY',
];
public function __construct(QuoterInterface $quoter, SchemaInterface $schema, ServerInfoInterface $serverInfo)
{
parent::__construct(
$quoter,
$schema,
$serverInfo,
new DDLQueryBuilder($this, $quoter, $schema),
new DMLQueryBuilder($this, $quoter, $schema),
new DQLQueryBuilder($this, $quoter),
new ColumnDefinitionBuilder($this),
);
}
}