Class: Doctrine_Import_Pgsql
Source Location: /Doctrine/Import/Pgsql.phpClass Doctrine_Import_Pgsql
Class Overview
Located in /Doctrine/Import/Pgsql.php [line 33] Doctrine_Connection_Module | --Doctrine_Import | --Doctrine_Import_PgsqlAuthor(s):
|
[ Top ]
Inherited Properties, Constants, and Methods
[ Top ]
Method Summary
array | listTableColumns() | lists table constraints |
array | listTableConstraints() | lists table constraints |
array | listTableIndexes() | list all indexes in a table |
array | listTables() | lists tables |
array | listTableTriggers() | lists table triggers |
array | listTableViews() | list the views in the database that reference a given table |
array | listTriggers() | lists all database triggers |
[ Top ]
Properties
mixed
$sql
= array(
'listDatabases' => 'SELECT datname FROM pg_database',
'listFunctions' => "SELECT
proname
FROM
pg_proc pr,
pg_type tp
WHERE
tp.oid = pr.prorettype
AND pr.proisagg = FALSE
AND tp.typname <> 'trigger'
AND pr.pronamespace IN
(SELECT oid FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema'",
'listSequences' => "SELECT
relname
FROM
pg_class
WHERE relkind = 'S' AND relnamespace IN
(SELECT oid FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')",
'listTables' => "SELECT
c.relname AS table_name
FROM pg_class c, pg_user u
WHERE c.relowner = u.usesysid
AND c.relkind = 'r'
AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname)
AND c.relname !~ '^(pg_|sql_)'
UNION
SELECT c.relname AS table_name
FROM pg_class c
WHERE c.relkind = 'r'
AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname)
AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner)
AND c.relname !~ '^pg_'",
'listViews' => 'SELECT viewname FROM pg_views',
'listUsers' => 'SELECT usename FROM pg_user',
'listTableConstraints' => "SELECT
relname
FROM
pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname = %s
AND pg_class.oid = pg_index.indrelid
AND (indisunique = 't' OR indisprimary = 't')
)",
'listTableIndexes' => "SELECT
relname
FROM
pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname = %s
AND pg_class.oid=pg_index.indrelid
AND indisunique != 't'
AND indisprimary != 't'
)",
'listTableColumns' => "SELECT
a.attnum,
a.attname AS field,
t.typname AS type,
format_type(a.atttypid, a.atttypmod) AS complete_type,
a.attnotnull AS isnotnull,
(SELECT 't'
FROM pg_index
WHERE c.oid = pg_index.indrelid
AND pg_index.indkey[0] = a.attnum
AND pg_index.indisprimary = 't'
) AS pri,
(SELECT pg_attrdef.adsrc
FROM pg_attrdef
WHERE c.oid = pg_attrdef.adrelid
AND pg_attrdef.adnum=a.attnum
) AS default
FROM pg_attribute a, pg_class c, pg_type t
WHERE c.relname = %s
AND a.attnum > 0
AND a.attrelid = c.oid
AND a.atttypid = t.oid
ORDER BY a.attnum",
) [line 36]
API Tags:'listDatabases' => 'SELECT datname FROM pg_database',
'listFunctions' => "SELECT
proname
FROM
pg_proc pr,
pg_type tp
WHERE
tp.oid = pr.prorettype
AND pr.proisagg = FALSE
AND tp.typname <> 'trigger'
AND pr.pronamespace IN
(SELECT oid FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema'",
'listSequences' => "SELECT
relname
FROM
pg_class
WHERE relkind = 'S' AND relnamespace IN
(SELECT oid FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')",
'listTables' => "SELECT
c.relname AS table_name
FROM pg_class c, pg_user u
WHERE c.relowner = u.usesysid
AND c.relkind = 'r'
AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname)
AND c.relname !~ '^(pg_|sql_)'
UNION
SELECT c.relname AS table_name
FROM pg_class c
WHERE c.relkind = 'r'
AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname)
AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner)
AND c.relname !~ '^pg_'",
'listViews' => 'SELECT viewname FROM pg_views',
'listUsers' => 'SELECT usename FROM pg_user',
'listTableConstraints' => "SELECT
relname
FROM
pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname = %s
AND pg_class.oid = pg_index.indrelid
AND (indisunique = 't' OR indisprimary = 't')
)",
'listTableIndexes' => "SELECT
relname
FROM
pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname = %s
AND pg_class.oid=pg_index.indrelid
AND indisunique != 't'
AND indisprimary != 't'
)",
'listTableColumns' => "SELECT
a.attnum,
a.attname AS field,
t.typname AS type,
format_type(a.atttypid, a.atttypmod) AS complete_type,
a.attnotnull AS isnotnull,
(SELECT 't'
FROM pg_index
WHERE c.oid = pg_index.indrelid
AND pg_index.indkey[0] = a.attnum
AND pg_index.indisprimary = 't'
) AS pri,
(SELECT pg_attrdef.adsrc
FROM pg_attrdef
WHERE c.oid = pg_attrdef.adrelid
AND pg_attrdef.adnum=a.attnum
) AS default
FROM pg_attribute a, pg_class c, pg_type t
WHERE c.relname = %s
AND a.attnum > 0
AND a.attrelid = c.oid
AND a.atttypid = t.oid
ORDER BY a.attnum",
) [line 36]
Access: | protected |
Redefinition of:
[ Top ]
Methods
listTableColumns [line 149]
|
lists table constraints
Parameters:string | $table: | database table name |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTableColumns()
- lists table constraints
[ Top ]
listTableConstraints [line 136]
|
lists table constraints
Parameters:string | $table: | database table name |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTableConstraints()
- lists table constraints
[ Top ]
listTableIndexes [line 189]
|
list all indexes in a table
Parameters:string | $table: | database table name |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTableIndexes()
- lists table constraints
[ Top ]
listTables [line 202]
|
lists tables
Parameters:string|null | $database: |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTables()
- lists tables
[ Top ]
listTableTriggers [line 212]
|
lists table triggers
Parameters:string | $table: | database table name |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTableTriggers()
- lists table triggers
[ Top ]
listTableViews [line 230]
|
list the views in the database that reference a given table
Parameters:string | $table: | database table name |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTableViews()
- lists table views
[ Top ]
listTriggers [line 126]
|
lists all database triggers
Parameters:string|null | $database: |
API Tags:
Access: | public |
Redefinition of:
- Doctrine_Import::listTriggers()
- lists all database triggers
[ Top ]