Skip to content

Commit

Permalink
Fix for #806
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed May 28, 2022
1 parent db421b2 commit 40b61e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions api.include.php
Expand Up @@ -6501,7 +6501,7 @@ public function getTables(): array
$results = $this->query($sql, [$this->database]);
$tables = $this->tables;
$results = array_filter($results, function ($v) use ($tables) {
return !$tables || in_array($v['TABLE_NAME'], $tables);
return $tables == ['all'] || in_array($v['TABLE_NAME'], $tables);
});
foreach ($results as &$result) {
$result['TABLE_REAL_NAME'] = $result['TABLE_NAME'];
Expand Down Expand Up @@ -6530,7 +6530,7 @@ public function getTables(): array

public function getTableColumns(string $tableName, string $type): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTableColumnsSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
foreach ($results as &$result) {
Expand Down Expand Up @@ -6579,7 +6579,7 @@ public function getTableColumns(string $tableName, string $type): array

public function getTablePrimaryKeys(string $tableName): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTablePrimaryKeysSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
$primaryKeys = [];
Expand All @@ -6591,7 +6591,7 @@ public function getTablePrimaryKeys(string $tableName): array

public function getTableForeignKeys(string $tableName): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTableForeignKeysSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
$foreignKeys = [];
Expand Down Expand Up @@ -11820,7 +11820,7 @@ class Config
'password' => '',
'database' => '',
'command' => '',
'tables' => '',
'tables' => 'all',
'mapping' => '',
'middlewares' => 'cors,errors',
'controllers' => 'records,geojson,openapi,status',
Expand Down
10 changes: 5 additions & 5 deletions api.php
Expand Up @@ -6501,7 +6501,7 @@ public function getTables(): array
$results = $this->query($sql, [$this->database]);
$tables = $this->tables;
$results = array_filter($results, function ($v) use ($tables) {
return !$tables || in_array($v['TABLE_NAME'], $tables);
return $tables == ['all'] || in_array($v['TABLE_NAME'], $tables);
});
foreach ($results as &$result) {
$result['TABLE_REAL_NAME'] = $result['TABLE_NAME'];
Expand Down Expand Up @@ -6530,7 +6530,7 @@ public function getTables(): array

public function getTableColumns(string $tableName, string $type): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTableColumnsSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
foreach ($results as &$result) {
Expand Down Expand Up @@ -6579,7 +6579,7 @@ public function getTableColumns(string $tableName, string $type): array

public function getTablePrimaryKeys(string $tableName): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTablePrimaryKeysSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
$primaryKeys = [];
Expand All @@ -6591,7 +6591,7 @@ public function getTablePrimaryKeys(string $tableName): array

public function getTableForeignKeys(string $tableName): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTableForeignKeysSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
$foreignKeys = [];
Expand Down Expand Up @@ -11820,7 +11820,7 @@ class Config
'password' => '',
'database' => '',
'command' => '',
'tables' => '',
'tables' => 'all',
'mapping' => '',
'middlewares' => 'cors,errors',
'controllers' => 'records,geojson,openapi,status',
Expand Down
2 changes: 1 addition & 1 deletion src/Tqdev/PhpCrudApi/Config.php
Expand Up @@ -12,7 +12,7 @@ class Config
'password' => '',
'database' => '',
'command' => '',
'tables' => '',
'tables' => 'all',
'mapping' => '',
'middlewares' => 'cors,errors',
'controllers' => 'records,geojson,openapi,status',
Expand Down
8 changes: 4 additions & 4 deletions src/Tqdev/PhpCrudApi/Database/GenericReflection.php
Expand Up @@ -104,7 +104,7 @@ public function getTables(): array
$results = $this->query($sql, [$this->database]);
$tables = $this->tables;
$results = array_filter($results, function ($v) use ($tables) {
return !$tables || in_array($v['TABLE_NAME'], $tables);
return $tables == ['all'] || in_array($v['TABLE_NAME'], $tables);
});
foreach ($results as &$result) {
$result['TABLE_REAL_NAME'] = $result['TABLE_NAME'];
Expand Down Expand Up @@ -133,7 +133,7 @@ public function getTables(): array

public function getTableColumns(string $tableName, string $type): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTableColumnsSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
foreach ($results as &$result) {
Expand Down Expand Up @@ -182,7 +182,7 @@ public function getTableColumns(string $tableName, string $type): array

public function getTablePrimaryKeys(string $tableName): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTablePrimaryKeysSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
$primaryKeys = [];
Expand All @@ -194,7 +194,7 @@ public function getTablePrimaryKeys(string $tableName): array

public function getTableForeignKeys(string $tableName): array
{
$tableRealName = $this->mapper->getTableRealName($tableName);
$tableRealName = $this->mapper->getTableRealName($tableName);
$sql = $this->getTableForeignKeysSQL();
$results = $this->query($sql, [$tableRealName, $this->database]);
$foreignKeys = [];
Expand Down

0 comments on commit 40b61e4

Please sign in to comment.