Browse Source

small bugfix for #191 and #192

Maurits van der Schee 8 years ago
parent
commit
71a62e9439
2 changed files with 16 additions and 4 deletions
  1. 16
    4
      api.php
  2. BIN
      data/blog.db

+ 16
- 4
api.php View File

@@ -94,8 +94,8 @@ class MySQL implements DatabaseInterface {
94 94
 				FROM 
95 95
 					"INFORMATION_SCHEMA"."COLUMNS" 
96 96
 				WHERE 
97
-					"TABLE_SCHEMA" = ? AND 
98
-					"TABLE_NAME" = ?
97
+					"TABLE_NAME" = ? AND
98
+					"TABLE_SCHEMA" = ?
99 99
 				ORDER BY
100 100
 					"ORDINAL_POSITION"'
101 101
 		);
@@ -249,6 +249,7 @@ class PostgreSQL implements DatabaseInterface {
249 249
 				from
250 250
 					"information_schema"."tables"
251 251
 				where
252
+					"table_schema" = \'public\' and
252 253
 					"table_catalog" = ?',
253 254
 			'reflect_table'=>'select
254 255
 					"table_name"
@@ -256,6 +257,7 @@ class PostgreSQL implements DatabaseInterface {
256 257
 					"information_schema"."tables"
257 258
 				where
258 259
 					"table_name" = ? and
260
+					"table_schema" = \'public\' and
259 261
 					"table_catalog" = ?',
260 262
 			'reflect_pk'=>'select
261 263
 					"column_name"
@@ -266,6 +268,7 @@ class PostgreSQL implements DatabaseInterface {
266 268
 					tc."constraint_type" = \'PRIMARY KEY\' and
267 269
 					tc."constraint_name" = ku."constraint_name" and
268 270
 					ku."table_name" = ? and
271
+					ku."table_schema" = \'public\' and
269 272
 					ku."table_catalog" = ?',
270 273
 			'reflect_belongs_to'=>'select
271 274
 					cu1."table_name",cu1."column_name",
@@ -279,6 +282,8 @@ class PostgreSQL implements DatabaseInterface {
279 282
 					cu2."constraint_name" = rc."unique_constraint_name" and
280 283
 					cu1."table_name" = ? and
281 284
 					cu2."table_name" in ? and
285
+					cu1."table_schema" = \'public\' and
286
+					cu2."table_schema" = \'public\' and
282 287
 					cu1."table_catalog" = ? and
283 288
 					cu2."table_catalog" = ?',
284 289
 			'reflect_has_many'=>'select
@@ -293,6 +298,8 @@ class PostgreSQL implements DatabaseInterface {
293 298
 					cu2."constraint_name" = rc."unique_constraint_name" and
294 299
 					cu1."table_name" in ? and
295 300
 					cu2."table_name" = ? and
301
+					cu1."table_schema" = \'public\' and
302
+					cu2."table_schema" = \'public\' and
296 303
 					cu1."table_catalog" = ? and
297 304
 					cu2."table_catalog" = ?',
298 305
 			'reflect_habtm'=>'select
@@ -316,6 +323,10 @@ class PostgreSQL implements DatabaseInterface {
316 323
 					cub1."table_catalog" = ? and
317 324
 					cua2."table_catalog" = ? and
318 325
 					cub2."table_catalog" = ? and
326
+					cua1."table_schema" = \'public\' and
327
+					cub1."table_schema" = \'public\' and
328
+					cua2."table_schema" = \'public\' and
329
+					cub2."table_schema" = \'public\' and
319 330
 					cua1."table_name" = cub1."table_name" and
320 331
 					cua2."table_name" = ? and
321 332
 					cub2."table_name" in ?',
@@ -324,7 +335,8 @@ class PostgreSQL implements DatabaseInterface {
324 335
 				from 
325 336
 					"information_schema"."columns" 
326 337
 				where
327
-					"table_name" like ? and
338
+					"table_name" = ? and
339
+					"table_schema" = \'public\' and
328 340
 					"table_catalog" = ?
329 341
 				order by
330 342
 					"ordinal_position"'
@@ -2248,7 +2260,7 @@ class PHP_CRUD_API {
2248 2260
 			foreach ($primaryKeys as $primaryKey) {
2249 2261
 				$table_fields[$table['name']][$primaryKey]->primaryKey = true;
2250 2262
 			}
2251
-			$result = $this->db->query($this->db->getSql('reflect_columns'),array($database,$table_list[0]));
2263
+			$result = $this->db->query($this->db->getSql('reflect_columns'),array($table_list[0],$database));
2252 2264
 			while ($row = $this->db->fetchRow($result)) {
2253 2265
 				if ($row[1]!==null) $table_fields[$table['name']][$row[0]]->default = $row[1];
2254 2266
 				$table_fields[$table['name']][$row[0]]->required = strtolower($row[2])=='no' && $row[1]===null;

BIN
data/blog.db View File


Loading…
Cancel
Save