forked from bashkarev/clickhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryBuilder.php
55 lines (49 loc) · 1.29 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
<?php
/**
* @copyright Copyright (c) 2017 Dmitry Bashkarev
* @license https://github.com/bashkarev/clickhouse/blob/master/LICENSE
* @link https://github.com/bashkarev/clickhouse#readme
*/
namespace bashkarev\clickhouse;
use yii\db\Exception;
/**
* @author Dmitry Bashkarev <[email protected]>
*/
class QueryBuilder extends \yii\db\QueryBuilder
{
/**
* @inheritdoc
*/
public function createTable($table, $columns, $options = null)
{
if ($options === null) {
throw new Exception('Specify engine type');
}
return parent::createTable($table, $columns, $options);
}
/**
* @inheritdoc
*/
public function buildFrom($tables, &$params)
{
$final = false;
if (isset($params['_final'])) {
$final = $params['_final'];
unset($params['_final']);
}
$from = parent::buildFrom($tables, $params);
if ($final === true) {
$from .= ' FINAL';
}
return $from;
}
/**
* @inheritdoc
*/
public function addColumn($table, $column, $type)
{
return 'ALTER TABLE ' . $this->db->quoteTableName($table)
. ' ADD COLUMN ' . $this->db->quoteColumnName($column) . ' '
. $this->getColumnType($type);
}
}