Skip to content

Commit 4db621f

Browse files
softariusHLeithner
authored andcommitted
Pg schema (#24999)
1 parent 93dbe71 commit 4db621f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

libraries/joomla/database/driver/postgresql.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function getTableCreate($tables)
391391
/**
392392
* Retrieves field information about a given table.
393393
*
394-
* @param string $table The name of the database table.
394+
* @param string $table The name of the database table. For PostgreSQL may start with a schema.
395395
* @param boolean $typeOnly True to only return field types.
396396
*
397397
* @return array An array of fields for the database table.
@@ -404,8 +404,18 @@ public function getTableColumns($table, $typeOnly = true)
404404
$this->connect();
405405

406406
$result = array();
407-
408407
$tableSub = $this->replacePrefix($table);
408+
$fn = explode('.', $tableSub);
409+
410+
if (count($fn) === 2)
411+
{
412+
$schema = $fn[0];
413+
$tableSub = $fn[1];
414+
}
415+
else
416+
{
417+
$schema = 'public';
418+
}
409419

410420
$this->setQuery('
411421
SELECT a.attname AS "column_name",
@@ -427,7 +437,7 @@ public function getTableColumns($table, $typeOnly = true)
427437
WHERE a.attrelid =
428438
(SELECT oid FROM pg_catalog.pg_class WHERE relname=' . $this->quote($tableSub) . '
429439
AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE
430-
nspname = \'public\')
440+
nspname = ' . $this->quote($schema) . ')
431441
)
432442
AND a.attnum > 0 AND NOT a.attisdropped
433443
ORDER BY a.attnum'

0 commit comments

Comments
 (0)