Browse Source

Merge pull request #192 from jr3cermak/master

Adding "x-dbtype" to show database field type
Maurits van der Schee 8 years ago
parent
commit
113c0006ca
1 changed files with 11 additions and 3 deletions
  1. 11
    3
      api.php

+ 11
- 3
api.php View File

@@ -95,8 +95,7 @@ class MySQL implements DatabaseInterface {
95 95
 					"INFORMATION_SCHEMA"."COLUMNS" 
96 96
 				WHERE 
97 97
 					"TABLE_SCHEMA" = ? AND 
98
-					"TABLE_NAME" = ?
99
-			'
98
+					"TABLE_NAME" = ?'
100 99
 		);
101 100
 	}
102 101
 
@@ -2355,7 +2354,7 @@ class PHP_CRUD_API {
2355 2354
 							echo '"'.$field.'": {';
2356 2355
 							echo '"type": "string"';
2357 2356
 							if (isset($action['fields'][$field]->type)) {
2358
-								echo ',"db-type": '.json_encode($action['fields'][$field]->type);
2357
+								echo ',"x-dbtype": '.json_encode($action['fields'][$field]->type);
2359 2358
 							}
2360 2359
 							if (isset($action['fields'][$field]->referenced)) {
2361 2360
 								echo ',"x-referenced": '.json_encode($action['fields'][$field]->referenced);
@@ -2387,6 +2386,9 @@ class PHP_CRUD_API {
2387 2386
 							if ($k>0) echo ',';
2388 2387
 							echo '"'.$field.'": {';
2389 2388
 							echo '"type": "string"';
2389
+							if (isset($action['fields'][$field]->type)) {
2390
+								echo ',"x-dbtype": '.json_encode($action['fields'][$field]->type);
2391
+							}
2390 2392
 							if (isset($action['fields'][$field]->referenced)) {
2391 2393
 								echo ',"x-referenced": '.json_encode($action['fields'][$field]->referenced);
2392 2394
 							}
@@ -2443,6 +2445,9 @@ class PHP_CRUD_API {
2443 2445
 							if ($k>0) echo ',';
2444 2446
 							echo '"'.$field.'": {';
2445 2447
 							echo '"type": "string"';
2448
+							if (isset($action['fields'][$field]->type)) {
2449
+								echo ',"x-dbtype": '.json_encode($action['fields'][$field]->type);
2450
+							}
2446 2451
 							if (isset($action['fields'][$field]->referenced)) {
2447 2452
 								echo ',"x-referenced": '.json_encode($action['fields'][$field]->referenced);
2448 2453
 							}
@@ -2470,6 +2475,9 @@ class PHP_CRUD_API {
2470 2475
 							if ($k>0) echo ',';
2471 2476
 							echo '"'.$field.'": {';
2472 2477
 							echo '"type": "string"';
2478
+							if (isset($action['fields'][$field]->type)) {
2479
+								echo ',"x-dbtype": '.json_encode($action['fields'][$field]->type);
2480
+							}
2473 2481
 							if (isset($action['fields'][$field]->referenced)) {
2474 2482
 								echo ',"x-referenced": '.json_encode($action['fields'][$field]->referenced);
2475 2483
 							}

Loading…
Cancel
Save