PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.3
Independent Analytics – WordPress Analytics Plugin v2.15.3
2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / illuminate / database / Schema / PostgresBuilder.php
independent-analytics / vendor / illuminate / database / Schema Last commit date
Grammars 3 weeks ago Blueprint.php 3 weeks ago Builder.php 3 weeks ago ColumnDefinition.php 3 weeks ago ForeignIdColumnDefinition.php 3 weeks ago ForeignKeyDefinition.php 3 weeks ago IndexDefinition.php 3 weeks ago MySqlBuilder.php 3 weeks ago MySqlSchemaState.php 3 weeks ago PostgresBuilder.php 3 weeks ago PostgresSchemaState.php 3 weeks ago SQLiteBuilder.php 3 weeks ago SchemaState.php 3 weeks ago SqlServerBuilder.php 3 weeks ago SqliteSchemaState.php 3 weeks ago
PostgresBuilder.php
179 lines
1 <?php
2
3 namespace IAWPSCOPED\Illuminate\Database\Schema;
4
5 use IAWPSCOPED\Illuminate\Database\Concerns\ParsesSearchPath;
6 /** @internal */
7 class PostgresBuilder extends Builder
8 {
9 use ParsesSearchPath {
10 parseSearchPath as baseParseSearchPath;
11 }
12 /**
13 * Create a database in the schema.
14 *
15 * @param string $name
16 * @return bool
17 */
18 public function createDatabase($name)
19 {
20 return $this->connection->statement($this->grammar->compileCreateDatabase($name, $this->connection));
21 }
22 /**
23 * Drop a database from the schema if the database exists.
24 *
25 * @param string $name
26 * @return bool
27 */
28 public function dropDatabaseIfExists($name)
29 {
30 return $this->connection->statement($this->grammar->compileDropDatabaseIfExists($name));
31 }
32 /**
33 * Determine if the given table exists.
34 *
35 * @param string $table
36 * @return bool
37 */
38 public function hasTable($table)
39 {
40 [$database, $schema, $table] = $this->parseSchemaAndTable($table);
41 $table = $this->connection->getTablePrefix() . $table;
42 return \count($this->connection->selectFromWriteConnection($this->grammar->compileTableExists(), [$database, $schema, $table])) > 0;
43 }
44 /**
45 * Drop all tables from the database.
46 *
47 * @return void
48 */
49 public function dropAllTables()
50 {
51 $tables = [];
52 $excludedTables = $this->grammar->escapeNames($this->connection->getConfig('dont_drop') ?? ['spatial_ref_sys']);
53 foreach ($this->getAllTables() as $row) {
54 $row = (array) $row;
55 if (empty(\array_intersect($this->grammar->escapeNames($row), $excludedTables))) {
56 $tables[] = $row['qualifiedname'] ?? \reset($row);
57 }
58 }
59 if (empty($tables)) {
60 return;
61 }
62 $this->connection->statement($this->grammar->compileDropAllTables($tables));
63 }
64 /**
65 * Drop all views from the database.
66 *
67 * @return void
68 */
69 public function dropAllViews()
70 {
71 $views = [];
72 foreach ($this->getAllViews() as $row) {
73 $row = (array) $row;
74 $views[] = $row['qualifiedname'] ?? \reset($row);
75 }
76 if (empty($views)) {
77 return;
78 }
79 $this->connection->statement($this->grammar->compileDropAllViews($views));
80 }
81 /**
82 * Drop all types from the database.
83 *
84 * @return void
85 */
86 public function dropAllTypes()
87 {
88 $types = [];
89 foreach ($this->getAllTypes() as $row) {
90 $row = (array) $row;
91 $types[] = \reset($row);
92 }
93 if (empty($types)) {
94 return;
95 }
96 $this->connection->statement($this->grammar->compileDropAllTypes($types));
97 }
98 /**
99 * Get all of the table names for the database.
100 *
101 * @return array
102 */
103 public function getAllTables()
104 {
105 return $this->connection->select($this->grammar->compileGetAllTables($this->parseSearchPath($this->connection->getConfig('search_path') ?: $this->connection->getConfig('schema'))));
106 }
107 /**
108 * Get all of the view names for the database.
109 *
110 * @return array
111 */
112 public function getAllViews()
113 {
114 return $this->connection->select($this->grammar->compileGetAllViews($this->parseSearchPath($this->connection->getConfig('search_path') ?: $this->connection->getConfig('schema'))));
115 }
116 /**
117 * Get all of the type names for the database.
118 *
119 * @return array
120 */
121 public function getAllTypes()
122 {
123 return $this->connection->select($this->grammar->compileGetAllTypes());
124 }
125 /**
126 * Get the column listing for a given table.
127 *
128 * @param string $table
129 * @return array
130 */
131 public function getColumnListing($table)
132 {
133 [$database, $schema, $table] = $this->parseSchemaAndTable($table);
134 $table = $this->connection->getTablePrefix() . $table;
135 $results = $this->connection->selectFromWriteConnection($this->grammar->compileColumnListing(), [$database, $schema, $table]);
136 return $this->connection->getPostProcessor()->processColumnListing($results);
137 }
138 /**
139 * Parse the database object reference and extract the database, schema, and table.
140 *
141 * @param string $reference
142 * @return array
143 */
144 protected function parseSchemaAndTable($reference)
145 {
146 $searchPath = $this->parseSearchPath(($this->connection->getConfig('search_path') ?: $this->connection->getConfig('schema')) ?: 'public');
147 $parts = \explode('.', $reference);
148 $database = $this->connection->getConfig('database');
149 // If the reference contains a database name, we will use that instead of the
150 // default database name for the connection. This allows the database name
151 // to be specified in the query instead of at the full connection level.
152 if (\count($parts) === 3) {
153 $database = $parts[0];
154 \array_shift($parts);
155 }
156 // We will use the default schema unless the schema has been specified in the
157 // query. If the schema has been specified in the query then we can use it
158 // instead of a default schema configured in the connection search path.
159 $schema = $searchPath[0];
160 if (\count($parts) === 2) {
161 $schema = $parts[0];
162 \array_shift($parts);
163 }
164 return [$database, $schema, $parts[0]];
165 }
166 /**
167 * Parse the "search_path" configuration value into an array.
168 *
169 * @param string|array|null $searchPath
170 * @return array
171 */
172 protected function parseSearchPath($searchPath)
173 {
174 return \array_map(function ($schema) {
175 return $schema === '$user' ? $this->connection->getConfig('username') : $schema;
176 }, $this->baseParseSearchPath($searchPath));
177 }
178 }
179