Passed
Push — master ( 527670...666a8e )
by Sergei
06:51 queued 02:16
created

Command::showDatabases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Yiisoft\Db\Driver\Pdo\AbstractPdoCommand;
8
9
/**
10
 * Implements a database command that can be executed against a PDO (PHP Data Object) database connection for MSSQL
11
 * Server.
12
 */
13
final class Command extends AbstractPdoCommand
14
{
15 10
    public function insertWithReturningPks(string $table, array $columns): bool|array
16
    {
17 10
        if (empty($this->db->getSchema()->getTableSchema($table)?->getPrimaryKey())) {
18 1
            if (parent::insert($table, $columns)->execute() === 0) {
19
                return false;
20
            }
21
22 1
            return [];
23
        }
24
25 9
        return parent::insertWithReturningPks($table, $columns);
26
    }
27
28 1
    public function showDatabases(): array
29
    {
30 1
        $sql = <<<SQL
31
        SELECT [name] FROM [sys].[databases] WHERE [name] NOT IN ('master', 'tempdb', 'model', 'msdb')
32 1
        SQL;
33
34 1
        return $this->setSql($sql)->queryColumn();
35
    }
36
}
37