ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
MDB2_Driver_Manager_pgsql Class Reference
+ Inheritance diagram for MDB2_Driver_Manager_pgsql:
+ Collaboration diagram for MDB2_Driver_Manager_pgsql:

Public Member Functions

 createDatabase ($name)
 create a new database More...
 
 dropDatabase ($name)
 drop an existing database More...
 
 alterTable ($name, $changes, $check)
 alter an existing table More...
 
 listDatabases ()
 list all databases More...
 
 listUsers ()
 list all users More...
 
 listViews ()
 list all views in the current database More...
 
 listTableViews ($table)
 list the views in the database that reference a given table More...
 
 listFunctions ()
 list all functions in the current database More...
 
 listTableTriggers ($table=null)
 list all triggers in the database that reference a given table More...
 
 listTables ()
 list all tables in the current database More...
 
 listTableFields ($table)
 list all fields in a table in the current database More...
 
 listTableIndexes ($table)
 list all indexes in a table More...
 
 listTableConstraints ($table)
 list all constraints in a table More...
 
 createSequence ($seq_name, $start=1)
 create sequence More...
 
 dropSequence ($seq_name)
 drop existing sequence More...
 
 listSequences ()
 list all sequences in the current database More...
 
- Public Member Functions inherited from MDB2_Driver_Manager_Common
 getFieldDeclarationList ($fields)
 Get declaration of a number of field in bulk. More...
 
 _fixSequenceName ($sqn, $check=false)
 Removes any formatting in an sequence name using the 'seqname_format' option. More...
 
 _fixIndexName ($idx)
 Removes any formatting in an index name using the 'idxname_format' option. More...
 
 createDatabase ($database)
 create a new database More...
 
 dropDatabase ($database)
 drop an existing database More...
 
 _getCreateTableQuery ($name, $fields, $options=array())
 Create a basic SQL query for a new table creation. More...
 
 _getTemporaryTableQuery ()
 A method to return the required SQL string that fits between CREATE ... TABLE to create the table as a temporary table. More...
 
 createTable ($name, $fields, $options=array())
 create a new table More...
 
 getTableCreationQuery ($name, $fields, $options=array())
 PATCH: For Testcases Only. More...
 
 dropTable ($name)
 drop an existing table More...
 
 alterTable ($name, $changes, $check)
 alter an existing table More...
 
 listDatabases ()
 list all databases More...
 
 listUsers ()
 list all users More...
 
 listViews ($database=null)
 list all views in the current database More...
 
 listTableViews ($table)
 list the views in the database that reference a given table More...
 
 listTableTriggers ($table=null)
 list all triggers in the database that reference a given table More...
 
 listFunctions ()
 list all functions in the current database More...
 
 listTables ($database=null)
 list all tables in the current database More...
 
 listTableFields ($table)
 list all fields in a table in the current database More...
 
 createIndex ($table, $name, $definition)
 Get the stucture of a field into an array. More...
 
 dropIndex ($table, $name)
 drop existing index More...
 
 listTableIndexes ($table)
 list all indexes in a table More...
 
 createConstraint ($table, $name, $definition)
 create a constraint on a table More...
 
 dropConstraint ($table, $name, $primary=false)
 drop existing constraint More...
 
 listTableConstraints ($table)
 list all constraints in a table More...
 
 createSequence ($seq_name, $start=1)
 create sequence More...
 
 dropSequence ($name)
 drop existing sequence More...
 
 listSequences ($database=null)
 list all sequences in the current database More...
 
- Public Member Functions inherited from MDB2_Module_Common
 __construct ($db_index)
 Constructor. More...
 
 MDB2_Module_Common ($db_index)
 PHP 4 Constructor. More...
 
getDBInstance ()
 Get the instance of MDB2 associated with the module instance. More...
 

Additional Inherited Members

- Data Fields inherited from MDB2_Module_Common
 $db_index
 

Detailed Description

Definition at line 56 of file pgsql.php.

Member Function Documentation

◆ alterTable()

MDB2_Driver_Manager_pgsql::alterTable (   $name,
  $changes,
  $check 
)

alter an existing table

Parameters
string$namename of the table that is intended to be changed.
array$changesassociative array that contains the details of each type of change that is intended to be performed. The types of changes that are currently supported are defined as follows:

name

New name for the table.

add

Associative array with the names of fields to be added as
 indexes of the array. The value of each entry of the array
 should be set to another associative array with the properties
 of the fields to be added. The properties of the fields should
 be the same as defined by the MDB2 parser.

remove

Associative array with the names of fields to be removed as indexes
 of the array. Currently the values assigned to each entry are ignored.
 An empty array should be used for future compatibility.

rename

Associative array with the names of fields to be renamed as indexes
 of the array. The value of each entry of the array should be set to
 another associative array with the entry named name with the new
 field name and the entry named Declaration that is expected to contain
 the portion of the field declaration already in DBMS specific SQL code
 as it is used in the CREATE TABLE statement.

change

Associative array with the names of the fields to be changed as indexes
 of the array. Keep in mind that if it is intended to change either the
 name of a field and any other properties, the change array entries
 should have the new names of the fields as array indexes.

The value of each entry of the array should be set to another associative
 array with the properties of the fields to that are meant to be changed as
 array entries. These entries should be assigned to the new values of the
 respective properties. The properties of the fields should be the same
 as defined by the MDB2 parser.

Example array( 'name' => 'userlist', 'add' => array( 'quota' => array( 'type' => 'integer', 'unsigned' => 1 ) ), 'remove' => array( 'file_limit' => array(), 'time_limit' => array() ), 'change' => array( 'name' => array( 'length' => '20', 'definition' => array( 'type' => 'text', 'length' => 20, ), ) ), 'rename' => array( 'sex' => array( 'name' => 'gender', 'definition' => array( 'type' => 'text', 'length' => 1, 'default' => 'M', ), ) ) )

Parameters
boolean$checkindicates whether the function should just check if the DBMS driver can perform the requested table alterations if the value is true or actually perform them otherwise. @access public
Returns
mixed MDB2_OK on success, a MDB2 error on failure

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 192 of file pgsql.php.

193 {
194 $db =& $this->getDBInstance();
195 if (PEAR::isError($db)) {
196 return $db;
197 }
198
199 foreach ($changes as $change_name => $change) {
200 switch ($change_name) {
201 case 'add':
202 case 'remove':
203 case 'change':
204 case 'name':
205 case 'rename':
206 break;
207 default:
208 return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
209 'change type "'.$change_name.'\" not yet supported', __FUNCTION__);
210 }
211 }
212
213 if ($check) {
214 return MDB2_OK;
215 }
216
217 if (!empty($changes['add']) && is_array($changes['add'])) {
218 foreach ($changes['add'] as $field_name => $field) {
219 $query = 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field);
220 $result = $db->exec("ALTER TABLE $name $query");
221 if (PEAR::isError($result)) {
222 return $result;
223 }
224 }
225 }
226
227 if (!empty($changes['remove']) && is_array($changes['remove'])) {
228 foreach ($changes['remove'] as $field_name => $field) {
229 $field_name = $db->quoteIdentifier($field_name, true);
230 $query = 'DROP ' . $field_name;
231 $result = $db->exec("ALTER TABLE $name $query");
232 if (PEAR::isError($result)) {
233 return $result;
234 }
235 }
236 }
237
238 if (!empty($changes['change']) && is_array($changes['change'])) {
239 foreach ($changes['change'] as $field_name => $field) {
240 $field_name = $db->quoteIdentifier($field_name, true);
241 if (!empty($field['type'])) {
242 $server_info = $db->getServerVersion();
243 if (PEAR::isError($server_info)) {
244 return $server_info;
245 }
246 if (is_array($server_info) && $server_info['major'] < 8) {
247 return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
248 'changing column type for "'.$change_name.'\" requires PostgreSQL 8.0 or above', __FUNCTION__);
249 }
250 $db->loadModule('Datatype', null, true);
251 $query = "ALTER $field_name TYPE ".$db->datatype->getTypeDeclaration($field['definition']);
252 $result = $db->exec("ALTER TABLE $name $query");
253 if (PEAR::isError($result)) {
254 return $result;
255 }
256 }
257 if (array_key_exists('default', $field)) {
258 $query = "ALTER $field_name SET DEFAULT ".$db->quote($field['definition']['default'], $field['definition']['type']);
259 $result = $db->exec("ALTER TABLE $name $query");
260 if (PEAR::isError($result)) {
261 return $result;
262 }
263 }
264 if (!empty($field['notnull'])) {
265 $query = "ALTER $field_name ".($field['definition']['notnull'] ? "SET" : "DROP").' NOT NULL';
266 $result = $db->exec("ALTER TABLE $name $query");
267 if (PEAR::isError($result)) {
268 return $result;
269 }
270 }
271 }
272 }
273
274 if (!empty($changes['rename']) && is_array($changes['rename'])) {
275 foreach ($changes['rename'] as $field_name => $field) {
276 $field_name = $db->quoteIdentifier($field_name, true);
277 $result = $db->exec("ALTER TABLE $name RENAME COLUMN $field_name TO ".$db->quoteIdentifier($field['name'], true));
278 if (PEAR::isError($result)) {
279 return $result;
280 }
281 }
282 }
283
284 $name_orig = $name;
285 $name = $db->quoteIdentifier($name, true);
286 if (!empty($changes['name'])) {
287 $indexes = $this->listTableIndexes($name_orig);
288 foreach ($indexes as $index) {
289 $new_name = str_replace($name_orig, $changes['name'], $index);
290 $result = $db->exec("ALTER INDEX {$index}_idx RENAME TO {$new_name}_idx");
291 if (PEAR::isError($result)) {
292// return $result;
293 }
294 }
295
296 $constraints = $this->listTableConstraints($name_orig);
297 foreach ($constraints as $constraint) {
298 $new_name = str_replace($name_orig, $changes['name'], $constraint);
299 $result = $db->exec("ALTER TABLE {$name_orig} RENAME CONSTRAINT {$constraint}_idx TO {$new_name}_idx;");
300 if (PEAR::isError($result)) {
301// return $result;
302 }
303 }
304
305 $change_name = $db->quoteIdentifier($changes['name'], true);
306 $result = $db->exec("ALTER TABLE $name RENAME TO ".$change_name);
307 if (PEAR::isError($result)) {
308 return $result;
309 }
310 }
311
312 return MDB2_OK;
313 }
$result
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
Definition: MDB2.php:72
const MDB2_ERROR_CANNOT_ALTER
Definition: MDB2.php:103
listTableIndexes($table)
list all indexes in a table
Definition: pgsql.php:595
listTableConstraints($table)
list all constraints in a table
Definition: pgsql.php:635
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), listTableConstraints(), listTableIndexes(), MDB2_ERROR_CANNOT_ALTER, and MDB2_OK.

+ Here is the call graph for this function:

◆ createDatabase()

MDB2_Driver_Manager_pgsql::createDatabase (   $name)

create a new database

Parameters
string$namename of the database that should be created
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 67 of file pgsql.php.

68 {
69 $db =& $this->getDBInstance();
70 if (PEAR::isError($db)) {
71 return $db;
72 }
73
74 $name = $db->quoteIdentifier($name, true);
75 return $db->standaloneQuery("CREATE DATABASE $name", null, true);
76 }

References MDB2_Module_Common\getDBInstance(), and PEAR\isError().

+ Here is the call graph for this function:

◆ createSequence()

MDB2_Driver_Manager_pgsql::createSequence (   $seq_name,
  $start = 1 
)

create sequence

Parameters
string$seq_namename of the sequence to be created
string$startstart value of the sequence; default is 1
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 678 of file pgsql.php.

679 {
680 $db =& $this->getDBInstance();
681 if (PEAR::isError($db)) {
682 return $db;
683 }
684
685 $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
686 return $db->exec("CREATE SEQUENCE $sequence_name INCREMENT 1".
687 ($start < 1 ? " MINVALUE $start" : '')." START $start");
688 }

References $start, MDB2_Module_Common\getDBInstance(), and PEAR\isError().

+ Here is the call graph for this function:

◆ dropDatabase()

MDB2_Driver_Manager_pgsql::dropDatabase (   $name)

drop an existing database

Parameters
string$namename of the database that should be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 88 of file pgsql.php.

89 {
90 $db =& $this->getDBInstance();
91 if (PEAR::isError($db)) {
92 return $db;
93 }
94
95 $name = $db->quoteIdentifier($name, true);
96 return $db->standaloneQuery("DROP DATABASE $name", null, true);
97 }

References MDB2_Module_Common\getDBInstance(), and PEAR\isError().

+ Here is the call graph for this function:

◆ dropSequence()

MDB2_Driver_Manager_pgsql::dropSequence (   $seq_name)

drop existing sequence

Parameters
string$seq_namename of the sequence to be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 700 of file pgsql.php.

701 {
702 $db =& $this->getDBInstance();
703 if (PEAR::isError($db)) {
704 return $db;
705 }
706
707 $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
708 return $db->exec("DROP SEQUENCE $sequence_name");
709 }

References MDB2_Module_Common\getDBInstance(), and PEAR\isError().

+ Here is the call graph for this function:

◆ listDatabases()

MDB2_Driver_Manager_pgsql::listDatabases ( )

list all databases

Returns
mixed array of database names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 324 of file pgsql.php.

325 {
326 $db =& $this->getDBInstance();
327 if (PEAR::isError($db)) {
328 return $db;
329 }
330
331 $query = 'SELECT datname FROM pg_database';
332 $result2 = $db->standaloneQuery($query, array('text'), false);
333 if (!MDB2::isResultCommon($result2)) {
334 return $result2;
335 }
336
337 $result = $result2->fetchCol();
338 $result2->free();
339 if (PEAR::isError($result)) {
340 return $result;
341 }
342 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
343 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
344 }
345 return $result;
346 }
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
Definition: MDB2.php:660

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2\isResultCommon(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listFunctions()

MDB2_Driver_Manager_pgsql::listFunctions ( )

list all functions in the current database

Returns
mixed array of function names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 443 of file pgsql.php.

444 {
445 $db =& $this->getDBInstance();
446 if (PEAR::isError($db)) {
447 return $db;
448 }
449
450 $query = "
451 SELECT
452 proname
453 FROM
454 pg_proc pr,
455 pg_type tp
456 WHERE
457 tp.oid = pr.prorettype
458 AND pr.proisagg = FALSE
459 AND tp.typname <> 'trigger'
460 AND pr.pronamespace IN
461 (SELECT oid FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')";
462 $result = $db->queryCol($query);
463 if (PEAR::isError($result)) {
464 return $result;
465 }
466 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
467 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
468 }
469 return $result;
470 }

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listSequences()

MDB2_Driver_Manager_pgsql::listSequences ( )

list all sequences in the current database

Returns
mixed array of sequence names on success, a MDB2 error on failure @access public

Definition at line 720 of file pgsql.php.

721 {
722 $db =& $this->getDBInstance();
723 if (PEAR::isError($db)) {
724 return $db;
725 }
726
727 $query = "SELECT relname FROM pg_class WHERE relkind = 'S' AND relnamespace IN";
728 $query.= "(SELECT oid FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')";
729 $table_names = $db->queryCol($query);
730 if (PEAR::isError($table_names)) {
731 return $table_names;
732 }
733 $result = array();
734 foreach ($table_names as $table_name) {
735 $result[] = $this->_fixSequenceName($table_name);
736 }
737 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
738 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
739 }
740 sort($result); // FSX patch
741
742 return $result;
743 }
_fixSequenceName($sqn, $check=false)
Removes any formatting in an sequence name using the 'seqname_format' option.
Definition: Common.php:116

References $query, $result, MDB2_Driver_Manager_Common\_fixSequenceName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableConstraints()

MDB2_Driver_Manager_pgsql::listTableConstraints (   $table)

list all constraints in a table

Parameters
string$tablename of table that should be used in method
Returns
mixed array of constraint names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 635 of file pgsql.php.

636 {
637 $db =& $this->getDBInstance();
638 if (PEAR::isError($db)) {
639 return $db;
640 }
641
642 $table = $db->quote($table, 'text');
643 $subquery = "SELECT indexrelid FROM pg_index, pg_class";
644 $subquery.= " WHERE pg_class.relname=$table AND pg_class.oid=pg_index.indrelid AND (indisunique = 't' OR indisprimary = 't')";
645 $query = "SELECT relname FROM pg_class WHERE oid IN ($subquery)";
646 $constraints = $db->queryCol($query);
647 if (PEAR::isError($constraints)) {
648 return $constraints;
649 }
650
651 $result = array();
652 foreach ($constraints as $constraint) {
653 $constraint = $this->_fixIndexName($constraint);
654 if (!empty($constraint)) {
655 $result[$constraint] = true;
656 }
657 }
658
659 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
660 && $db->options['field_case'] == CASE_LOWER
661 ) {
662 $result = array_change_key_case($result, $db->options['field_case']);
663 }
664 return array_keys($result);
665 }
_fixIndexName($idx)
Removes any formatting in an index name using the 'idxname_format' option.
Definition: Common.php:144

References $query, $result, MDB2_Driver_Manager_Common\_fixIndexName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

Referenced by alterTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listTableFields()

MDB2_Driver_Manager_pgsql::listTableFields (   $table)

list all fields in a table in the current database

Parameters
string$tablename of table that should be used in method
Returns
mixed array of field names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 564 of file pgsql.php.

565 {
566 $db =& $this->getDBInstance();
567 if (PEAR::isError($db)) {
568 return $db;
569 }
570
571 $table = $db->quoteIdentifier($table, true);
572 $db->setLimit(1);
573 $result2 = $db->query("SELECT * FROM $table");
574 if (PEAR::isError($result2)) {
575 return $result2;
576 }
577 $result = $result2->getColumnNames();
578 $result2->free();
579 if (PEAR::isError($result)) {
580 return $result;
581 }
582 return array_flip($result);
583 }

References $result, MDB2_Module_Common\getDBInstance(), and PEAR\isError().

+ Here is the call graph for this function:

◆ listTableIndexes()

MDB2_Driver_Manager_pgsql::listTableIndexes (   $table)

list all indexes in a table

Parameters
string$tablename of table that should be used in method
Returns
mixed array of index names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 595 of file pgsql.php.

596 {
597 $db =& $this->getDBInstance();
598 if (PEAR::isError($db)) {
599 return $db;
600 }
601
602 $table = $db->quote($table, 'text');
603 $subquery = "SELECT indexrelid FROM pg_index, pg_class";
604 $subquery.= " WHERE pg_class.relname=$table AND pg_class.oid=pg_index.indrelid AND indisunique != 't' AND indisprimary != 't'";
605 $query = "SELECT relname FROM pg_class WHERE oid IN ($subquery)";
606 $indexes = $db->queryCol($query, 'text');
607 if (PEAR::isError($indexes)) {
608 return $indexes;
609 }
610
611 $result = array();
612 foreach ($indexes as $index) {
613 $index = $this->_fixIndexName($index);
614 if (!empty($index)) {
615 $result[$index] = true;
616 }
617 }
618
619 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
620 $result = array_change_key_case($result, $db->options['field_case']);
621 }
622 return array_keys($result);
623 }

References $query, $result, MDB2_Driver_Manager_Common\_fixIndexName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

Referenced by alterTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listTables()

MDB2_Driver_Manager_pgsql::listTables ( )

list all tables in the current database

Returns
mixed array of table names on success, a MDB2 error on failure @access public

Definition at line 516 of file pgsql.php.

517 {
518 $db =& $this->getDBInstance();
519 if (PEAR::isError($db)) {
520 return $db;
521 }
522
523 // gratuitously stolen from PEAR DB _getSpecialQuery in pgsql.php
524 $query = 'SELECT c.relname AS "Name"'
525 . ' FROM pg_class c, pg_user u'
526 . ' WHERE c.relowner = u.usesysid'
527 . " AND c.relkind = 'r'"
528 . ' AND NOT EXISTS'
529 . ' (SELECT 1 FROM pg_views'
530 . ' WHERE viewname = c.relname)'
531 . " AND c.relname !~ '^(pg_|sql_)'"
532 . ' UNION'
533 . ' SELECT c.relname AS "Name"'
534 . ' FROM pg_class c'
535 . " WHERE c.relkind = 'r'"
536 . ' AND NOT EXISTS'
537 . ' (SELECT 1 FROM pg_views'
538 . ' WHERE viewname = c.relname)'
539 . ' AND NOT EXISTS'
540 . ' (SELECT 1 FROM pg_user'
541 . ' WHERE usesysid = c.relowner)'
542 . " AND c.relname !~ '^pg_'";
543 $result = $db->queryCol($query);
544 if (PEAR::isError($result)) {
545 return $result;
546 }
547 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
548 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
549 }
550 sort($result); // FSX Patch
551 return $result;
552 }

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableTriggers()

MDB2_Driver_Manager_pgsql::listTableTriggers (   $table = null)

list all triggers in the database that reference a given table

Parameters
stringtable for which all referenced triggers should be found
Returns
mixed array of trigger names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 482 of file pgsql.php.

483 {
484 $db =& $this->getDBInstance();
485 if (PEAR::isError($db)) {
486 return $db;
487 }
488
489 $query = 'SELECT trg.tgname AS trigger_name
490 FROM pg_trigger trg,
491 pg_class tbl
492 WHERE trg.tgrelid = tbl.oid';
493 if (!is_null($table)) {
494 $table = $db->quote(strtoupper($table), 'text');
495 $query .= " AND tbl.relname = $table";
496 }
497 $result = $db->queryCol($query);
498 if (PEAR::isError($result)) {
499 return $result;
500 }
501 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
502 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
503 }
504 return $result;
505 }

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableViews()

MDB2_Driver_Manager_pgsql::listTableViews (   $table)

list the views in the database that reference a given table

Parameters
stringtable for which all referenced views should be found
Returns
mixed array of view names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 415 of file pgsql.php.

416 {
417 $db =& $this->getDBInstance();
418 if (PEAR::isError($db)) {
419 return $db;
420 }
421
422 $query = 'SELECT viewname FROM pg_views NATURAL JOIN pg_tables';
423 $query.= ' WHERE tablename ='.$db->quote($table, 'text');
424 $result = $db->queryCol($query);
425 if (PEAR::isError($result)) {
426 return $result;
427 }
428 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
429 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
430 }
431 return $result;
432 }

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listUsers()

MDB2_Driver_Manager_pgsql::listUsers ( )

list all users

Returns
mixed array of user names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 357 of file pgsql.php.

358 {
359 $db =& $this->getDBInstance();
360 if (PEAR::isError($db)) {
361 return $db;
362 }
363
364 $query = 'SELECT usename FROM pg_user';
365 $result2 = $db->standaloneQuery($query, array('text'), false);
366 if (!MDB2::isResultCommon($result2)) {
367 return $result2;
368 }
369
370 $result = $result2->fetchCol();
371 $result2->free();
372 return $result;
373 }

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2\isResultCommon().

+ Here is the call graph for this function:

◆ listViews()

MDB2_Driver_Manager_pgsql::listViews ( )

list all views in the current database

Returns
mixed array of view names on success, a MDB2 error on failure @access public

Definition at line 384 of file pgsql.php.

385 {
386 $db =& $this->getDBInstance();
387 if (PEAR::isError($db)) {
388 return $db;
389 }
390
391 $query = "SELECT viewname
392 FROM pg_views
393 WHERE schemaname NOT IN ('pg_catalog', 'information_schema')
394 AND viewname !~ '^pg_'";
395 $result = $db->queryCol($query);
396 if (PEAR::isError($result)) {
397 return $result;
398 }
399 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
400 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
401 }
402 return $result;
403 }

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: