Completed
Pull Request — master (#32)
by
unknown
19:41 queued 16:44
created

Crate057Platform::getListTableConstraintsSQL()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * Licensed to CRATE Technology GmbH("Crate") under one or more contributor
4
 * license agreements.  See the NOTICE file distributed with this work for
5
 * additional information regarding copyright ownership.  Crate licenses
6
 * this file to you under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.  You may
8
 * obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15
 * License for the specific language governing permissions and limitations
16
 * under the License.
17
 *
18
 * However, if you have executed another commercial license agreement
19
 * with Crate these terms will supersede the license and you may use the
20
 * software solely pursuant to the terms of the relevant commercial agreement.
21
 */
22
23
namespace Crate\DBAL\Platforms;
24
25
26
class Crate057Platform extends CratePlatform
27
{
28
    /**
29
     * {@inheritDoc}
30
     */
31 6
    public function __construct()
32
    {
33 6
        parent::__construct();
34 6
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 12
    public function getListTablesSQL()
40
    {
41
        return "SELECT table_name, table_schema FROM information_schema.tables " .
42 12
        "WHERE table_schema = 'doc' OR table_schema = 'blob'";
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 3
    public function getListTableColumnsSQL($table, $database = null)
49
    {
50 3
        $t = explode('.', $table);
51 3
        if (count($t) == 1) {
52 3
            array_unshift($t, 'doc');
53 3
        }
54
        // todo: make safe
55
        return "SELECT * from information_schema.columns " .
56 3
            "WHERE table_name = '$t[1]' AND table_schema = '$t[0]'";
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62 3
    public function getListTableConstraintsSQL($table, $database = null)
63
    {
64 3
        $t = explode('.', $table);
65 3
        if (count($t) == 1) {
66 3
            array_unshift($t, 'doc');
67 3
        }
68
        // todo: make safe
69
        return "SELECT constraint_name, constraint_type from information_schema.table_constraints " .
70 3
        "WHERE table_name = '$t[1]' AND table_schema = '$t[0]' AND constraint_type = 'PRIMARY_KEY'";
71
    }
72
}