• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

misantron / dbunit / 4562384438

pending completion
4562384438

push

github

Aleksandr Ivanov
Fix build status badge display

635 of 1200 relevant lines covered (52.92%)

5.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Database/Metadata/Oci.php
1
<?php
2

3
/*
4
 * This file is part of DbUnit.
5
 *
6
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace PHPUnit\DbUnit\Database\Metadata;
13

14
/**
15
 * Provides functionality to retrieve meta data from an Oracle database.
16
 */
17
class Oci extends AbstractMetadata
18
{
19
    /**
20
     * No character used to quote schema objects.
21
     *
22
     * @var string
23
     */
24
    protected $schemaObjectQuoteChar = '';
25

26
    /**
27
     * The command used to perform a TRUNCATE operation.
28
     *
29
     * @var string
30
     */
31
    protected $truncateCommand = 'TRUNCATE TABLE';
32

33
    /**
34
     * @var array
35
     */
36
    protected $columns = [];
37

38
    /**
39
     * @var array
40
     */
41
    protected $keys = [];
42

43
    /**
44
     * Returns an array containing the names of all the tables in the database.
45
     *
46
     * @return array
47
     */
48
    public function getTableNames()
49
    {
50
        $tableNames = [];
×
51

52
        $query = "SELECT table_name
×
53
                    FROM cat
54
                   WHERE table_type='TABLE'
55
                   ORDER BY table_name";
×
56

57
        $result = $this->pdo->query($query);
×
58

59
        while ($tableName = $result->fetchColumn(0)) {
×
60
            $tableNames[] = $tableName;
×
61
        }
62

63
        return $tableNames;
×
64
    }
65

66
    /**
67
     * Returns an array containing the names of all the columns in the
68
     * $tableName table,
69
     *
70
     * @param string $tableName
71
     *
72
     * @return array
73
     */
74
    public function getTableColumns($tableName)
75
    {
76
        if (!isset($this->columns[$tableName])) {
×
77
            $this->loadColumnInfo($tableName);
×
78
        }
79

80
        return $this->columns[$tableName];
×
81
    }
82

83
    /**
84
     * Returns an array containing the names of all the primary key columns in
85
     * the $tableName table.
86
     *
87
     * @param string $tableName
88
     *
89
     * @return array
90
     */
91
    public function getTablePrimaryKeys($tableName)
92
    {
93
        if (!isset($this->keys[$tableName])) {
×
94
            $this->loadColumnInfo($tableName);
×
95
        }
96

97
        return $this->keys[$tableName];
×
98
    }
99

100
    /**
101
     * Loads column info from a oracle database.
102
     *
103
     * @param string $tableName
104
     */
105
    protected function loadColumnInfo($tableName): void
106
    {
107
        $ownerQuery    = '';
×
108
        $conOwnerQuery = '';
×
109
        $tableParts    = $this->splitTableName($tableName);
×
110

111
        $this->columns[$tableName] = [];
×
112
        $this->keys[$tableName]    = [];
×
113

114
        if (!empty($tableParts['schema'])) {
×
115
            $ownerQuery    = " AND OWNER = '{$tableParts['schema']}'";
×
116
            $conOwnerQuery = " AND a.owner = '{$tableParts['schema']}'";
×
117
        }
118

119
        $query = "SELECT DISTINCT COLUMN_NAME
×
120
                    FROM USER_TAB_COLUMNS
121
                   WHERE TABLE_NAME='" . $tableParts['table'] . "'
×
122
                    $ownerQuery
×
123
                   ORDER BY COLUMN_NAME";
×
124

125
        $result = $this->pdo->query($query);
×
126

127
        while ($columnName = $result->fetchColumn(0)) {
×
128
            $this->columns[$tableName][] = $columnName;
×
129
        }
130

131
        $keyQuery = "SELECT b.column_name
×
132
                       FROM user_constraints a, user_cons_columns b
133
                      WHERE a.constraint_type='P'
134
                        AND a.constraint_name=b.constraint_name
135
                        $conOwnerQuery
×
136
                        AND a.table_name = '" . $tableParts['table'] . "' ";
×
137

138
        $result = $this->pdo->query($keyQuery);
×
139

140
        while ($columnName = $result->fetchColumn(0)) {
×
141
            $this->keys[$tableName][] = $columnName;
×
142
        }
143
    }
144
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc