@@ -65,8 +65,8 @@ public function formatDateInterval(\DateInterval $value): string
6565
6666 public function formatLike (string $ value , int $ pos ): string
6767 {
68- $ bs = substr ($ this ->connection ->quote ('\\' ), 1 , -1 ); // standard_conforming_strings = on/off
69- $ value = substr ($ this ->connection ->quote ($ value ), 1 , -1 );
68+ $ bs = substr ($ this ->pdo ->quote ('\\' ), 1 , -1 ); // standard_conforming_strings = on/off
69+ $ value = substr ($ this ->pdo ->quote ($ value ), 1 , -1 );
7070 $ value = strtr ($ value , ['% ' => $ bs . '% ' , '_ ' => $ bs . '_ ' , '\\' => '\\\\' ]);
7171 return ($ pos <= 0 ? "'% " : "' " ) . $ value . ($ pos >= 0 ? "%' " : "' " );
7272 }
@@ -93,8 +93,7 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset): void
9393
9494 public function getTables (): array
9595 {
96- $ tables = [];
97- foreach ($ this ->connection ->query (<<<'X'
96+ return $ this ->pdo ->query (<<<'X'
9897 SELECT DISTINCT ON (c.relname)
9998 c.relname::varchar AS name,
10099 c.relkind IN ('v', 'm') AS view,
@@ -107,18 +106,14 @@ public function getTables(): array
107106 AND n.nspname = ANY (pg_catalog.current_schemas(FALSE))
108107 ORDER BY
109108 c.relname
110- X) as $ row ) {
111- $ tables [] = (array ) $ row ;
112- }
113-
114- return $ tables ;
109+ X)->fetchAll (\PDO ::FETCH_ASSOC );
115110 }
116111
117112
118113 public function getColumns (string $ table ): array
119114 {
120115 $ columns = [];
121- foreach ($ this ->connection ->query (<<<X
116+ foreach ($ this ->pdo ->query (<<<X
122117 SELECT
123118 a.attname::varchar AS name,
124119 c.relname::varchar AS table,
@@ -140,13 +135,12 @@ public function getColumns(string $table): array
140135 LEFT JOIN pg_catalog.pg_constraint AS co ON co.connamespace = c.relnamespace AND contype = 'p' AND co.conrelid = c.oid AND a.attnum = ANY(co.conkey)
141136 WHERE
142137 c.relkind IN ('r', 'v', 'm', 'p')
143- AND c.oid = {$ this ->connection ->quote ($ this ->delimiteFQN ($ table ))}::regclass
138+ AND c.oid = {$ this ->pdo ->quote ($ this ->delimiteFQN ($ table ))}::regclass
144139 AND a.attnum > 0
145140 AND NOT a.attisdropped
146141 ORDER BY
147142 a.attnum
148- X ) as $ row ) {
149- $ column = (array ) $ row ;
143+ X , \PDO ::FETCH_ASSOC ) as $ column ) {
150144 $ column ['type ' ] = Nette \Database \Helpers::detectType ($ column ['type ' ]);
151145 $ column ['vendor ' ] = $ column ;
152146 unset($ column ['sequence ' ]);
@@ -161,7 +155,7 @@ public function getColumns(string $table): array
161155 public function getIndexes (string $ table ): array
162156 {
163157 $ indexes = [];
164- foreach ($ this ->connection ->query (<<<X
158+ foreach ($ this ->pdo ->query (<<<X
165159 SELECT
166160 c2.relname::varchar AS name,
167161 i.indisunique AS unique,
@@ -174,7 +168,7 @@ public function getIndexes(string $table): array
174168 LEFT JOIN pg_catalog.pg_attribute AS a ON c1.oid = a.attrelid AND a.attnum = ANY(i.indkey)
175169 WHERE
176170 c1.relkind IN ('r', 'p')
177- AND c1.oid = {$ this ->connection ->quote ($ this ->delimiteFQN ($ table ))}::regclass
171+ AND c1.oid = {$ this ->pdo ->quote ($ this ->delimiteFQN ($ table ))}::regclass
178172 X ) as $ row ) {
179173 $ id = $ row ['name ' ];
180174 $ indexes [$ id ]['name ' ] = $ id ;
@@ -190,7 +184,7 @@ public function getIndexes(string $table): array
190184 public function getForeignKeys (string $ table ): array
191185 {
192186 /* Doesn't work with multi-column foreign keys */
193- return $ this ->connection ->query (<<<X
187+ return $ this ->pdo ->query (<<<X
194188 SELECT
195189 co.conname::varchar AS name,
196190 al.attname::varchar AS local,
@@ -205,9 +199,9 @@ public function getForeignKeys(string $table): array
205199 JOIN pg_catalog.pg_attribute AS af ON af.attrelid = cf.oid AND af.attnum = co.confkey[1]
206200 WHERE
207201 co.contype = 'f'
208- AND cl.oid = {$ this ->connection ->quote ($ this ->delimiteFQN ($ table ))}::regclass
202+ AND cl.oid = {$ this ->pdo ->quote ($ this ->delimiteFQN ($ table ))}::regclass
209203 AND nf.nspname = ANY (pg_catalog.current_schemas(FALSE))
210- X )->fetchAll ();
204+ X )->fetchAll (\ PDO :: FETCH_ASSOC );
211205 }
212206
213207
0 commit comments