File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,18 @@ public function __call(?string $method = null, array $params = [])
51
51
public function getScheme (): array
52
52
{
53
53
if (null === $ this ->scheme ) {
54
- $ raw = $ this ->medoo ->query ('DESCRIBE ' .$ this ->getTable ())->fetchAll ();
54
+ switch ($ this ->config ('medoo.database_type ' )) {
55
+ case 'pgsql ' :
56
+ $ query = 'SELECT column_name AS "Field" FROM information_schema.COLUMNS WHERE table_name= \'' .$ this ->getTable ().'\'' ;
57
+ break ;
58
+ default :
59
+ $ query = 'DESCRIBE ' .$ this ->getTable ();
60
+ break ;
61
+ }
62
+ $ raw = $ this ->medoo ->query ($ query )->fetchAll ();
55
63
$ this ->scheme = [];
56
64
foreach ($ raw as $ field ) {
57
- $ this ->scheme [$ field ['Field ' ]] = $ field ;
65
+ $ this ->scheme [] = $ field ['Field ' ];
58
66
}
59
67
}
60
68
@@ -76,13 +84,12 @@ public function save(bool $validate = true): self
76
84
throw new Exception ('Entity ' .$ this ->__getEntityName ().' data is not valid ' );
77
85
}
78
86
79
- /**
87
+ /*
80
88
* Remove fields that not exists in DB table scheme,
81
89
* to avoid thrown exceptions on saving garbadge fields.
82
90
*/
83
- $ scheme = \array_keys ($ this ->getScheme ());
84
91
foreach ($ this ->data as $ key => $ value ) {
85
- if (!\in_array ($ key , $ scheme , true )) {
92
+ if (!\in_array ($ key , $ this -> getScheme () , true )) {
86
93
unset($ this ->data [$ key ]);
87
94
}
88
95
}
You can’t perform that action at this time.
0 commit comments