/**
* Manage aggregates in a database
*
- * $Id: aggregates.php,v 1.23 2007/07/16 21:27:28 ioguix Exp $
+ * $Id: aggregates.php,v 1.24 2007/08/31 18:30:10 ioguix Exp $
*/
// Include application functions
$columns = array(
'aggrname' => array(
'title' => $lang['strname'],
- 'field' => 'proname',
+ 'field' => field('proname'),
'url' => "redirect.php?subject=aggregate&action=properties&{$misc->href}&",
'vars' => array('aggrname' => 'proname', 'aggrtype' => 'proargtypes'),
),
'aggrtype' => array(
'title' => $lang['strtype'],
- 'field' => 'proargtypes',
+ 'field' => field('proargtypes'),
),
'aggrtransfn' => array(
'title' => $lang['straggrsfunc'],
- 'field' => 'aggtransfn',
+ 'field' => field('aggtransfn'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'usename',
+ 'field' => field('usename'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'aggrcomment',
+ 'field' => field('aggrcomment'),
),
);
/**
* Manage databases within a server
*
- * $Id: all_db.php,v 1.56 2007/07/17 14:59:52 ioguix Exp $
+ * $Id: all_db.php,v 1.57 2007/08/31 18:30:10 ioguix Exp $
*/
// Include application functions
$columns = array(
'database' => array(
'title' => $lang['strdatabase'],
- 'field' => 'datname',
+ 'field' => field('datname'),
'url' => "redirect.php?subject=database&{$misc->href}&",
'vars' => array('database' => 'datname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'datowner',
+ 'field' => field('datowner'),
),
'encoding' => array(
'title' => $lang['strencoding'],
- 'field' => 'datencoding',
+ 'field' => field('datencoding'),
),
'tablespace' => array(
'title' => $lang['strtablespace'],
- 'field' => 'tablespace',
+ 'field' => field('tablespace'),
),
'dbsize' => array(
'title' => $lang['strsize'],
- 'field' => 'dbsize',
+ 'field' => field('dbsize'),
'type' => 'prettysize',
),
'actions' => array(
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'datcomment',
+ 'field' => field('datcomment'),
),
);
/**
* Manage casts in a database
*
- * $Id: casts.php,v 1.14 2007/07/12 19:26:22 xzilla Exp $
+ * $Id: casts.php,v 1.15 2007/08/31 18:30:10 ioguix Exp $
*/
// Include application functions
$columns = array(
'source_type' => array(
'title' => $lang['strsourcetype'],
- 'field' => 'castsource',
+ 'field' => field('castsource'),
),
'target_type' => array(
'title' => $lang['strtargettype'],
- 'field' => 'casttarget',
+ 'field' => field('casttarget'),
),
'function' => array(
'title' => $lang['strfunction'],
- 'field' => 'castfunc',
+ 'field' => field('castfunc'),
'params'=> array('null' => $lang['strbinarycompat']),
),
'implicit' => array(
'title' => $lang['strimplicit'],
- 'field' => 'castcontext',
+ 'field' => field('castcontext'),
'type' => 'callback',
'params'=> array('function' => 'renderCastContext', 'align' => 'center'),
),
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.158 2007/07/19 19:51:17 xzilla Exp $
+ * $Id: Misc.php,v 1.159 2007/08/31 18:30:11 ioguix Exp $
*/
class Misc {
break;
default:
echo "<td class=\"data{$id}\">";
- if (array_key_exists($column['field'], $tabledata->fields)) {
+ $val = value($column['field'], $tabledata->fields);
+ if (!is_null($val)) {
if (isset($column['url'])) {
echo "<a href=\"{$column['url']}";
- if ($column['url'] === '') echo '?';
$misc->printUrlVars($column['vars'], $tabledata->fields);
echo "\">";
}
-
$type = isset($column['type']) ? $column['type'] : null;
$params = isset($column['params']) ? $column['params'] : array();
- echo $misc->printVal($tabledata->fields[$column['field']], $type, $params);
+ echo $misc->printVal($val, $type, $params);
+ if (isset($column['url'])) echo "</a>";
}
-
- if (isset($column['url'])) echo "</a>";
echo "</td>\n";
break;
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.165 2007/07/20 04:38:34 xzilla Exp $
+ * $Id: Postgres73.php,v 1.166 2007/08/31 18:30:11 ioguix Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
// Constraint functions
/**
- * A function for getting all columns linked by foreign keys in a table
+ * Returns a list of all constraints on a table,
+ * including constraint name, definition, related col and referenced namespace,
+ * table and col if needed
* @param $table the table where we are looking for fk
- * @param $schema the table's schema
- * @return a recordset of fk(s) infos
- * return null if table hasn't fk
+ * @return a recordset
*/
- function getForeignKeys($table, $schema) {
+ function getConstraints($table) {
global $data;
$data->clean($table);
- $data->clean($schema);
- // get the max number of col in a fk
- $sql = "SELECT DISTINCT
- max(SUBSTRING(array_dims(c.conkey) FROM '^\\\[.*:(.*)\\\]$')) as nb
- FROM
- pg_catalog.pg_constraint AS c,
- pg_catalog.pg_class AS r,
- pg_catalog.pg_namespace AS ns
- WHERE
- c.contype = 'f' AND c.conrelid = r.oid
- AND r.relname = '$table' AND r.relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='$schema')";
+ // get the max number of col used in a constraint for the table
+ $sql = "SELECT DISTINCT
+ max(SUBSTRING(array_dims(c.conkey) FROM '^\\\[.*:(.*)\\\]$')) as nb
+ FROM
+ pg_catalog.pg_constraint AS c
+ JOIN pg_catalog.pg_class AS r ON (c.conrelid = r.oid)
+ JOIN pg_catalog.pg_namespace AS ns ON r.relnamespace=ns.oid
+ WHERE
+ r.relname = '$table' AND ns.nspname='". $this->_schema ."'";
$rs = $this->selectSet($sql);
- //if we got the max number of col, this table have fks...
- if (!$rs->EOF) {
- $sql = "SELECT
- c.conname, ns1.nspname as p_schema, r1.relname as p_table, ns2.nspname as f_schema, r2.relname as f_table, pf.attname as p_field, ff.attname AS f_field
+
+ if ($rs->EOF) $max_col = 0;
+ else $max_col = $rs->fields['nb'];
+
+ $sql = '
+ SELECT
+ c.contype, c.conname, pg_catalog.pg_get_constraintdef(c.oid, true) AS consrc,
+ ns1.nspname as p_schema, r1.relname as p_table, ns2.nspname as f_schema,
+ r2.relname as f_table, f1.attname as p_field, f2.attname as f_field
FROM
- pg_catalog.pg_constraint AS c,
- pg_catalog.pg_class AS r1,
- pg_catalog.pg_class AS r2,
- pg_catalog.pg_namespace AS ns1,
- pg_catalog.pg_namespace AS ns2,
- pg_catalog.pg_attribute AS pf,
- pg_catalog.pg_attribute AS ff
- WHERE
- c.contype='f'
- AND c.conrelid=r1.oid
- AND c.confrelid=r2.oid
- AND r1.relnamespace=ns1.oid
- AND r2.relnamespace=ns2.oid
- AND pf.attrelid=r1.oid
- AND ff.attrelid=r2.oid
- AND r1.relname = '$table' AND r1.relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='$schema')
- AND ((pf.attnum=conkey[1] AND ff.attnum=confkey[1])";
-
- for ($i = 2; $i <= $rs->fields['nb']; $i++) {
- $sql.= " OR (pf.attnum=conkey[$i] AND ff.attnum=confkey[$i])";
- }
- $sql.= ")";
-
- return $this->selectSet($sql);
+ pg_catalog.pg_constraint AS c
+ JOIN pg_catalog.pg_class AS r1 ON (c.conrelid=r1.oid)
+ JOIN pg_catalog.pg_attribute AS f1 ON (f1.attrelid=r1.oid AND (f1.attnum=c.conkey[1]';
+ for ($i = 2; $i <= $rs->fields['nb']; $i++) {
+ $sql.= " OR f1.attnum=c.conkey[$i]";
}
- return null;
+ $sql.= '))
+ JOIN pg_catalog.pg_namespace AS ns1 ON r1.relnamespace=ns1.oid
+ LEFT JOIN (
+ pg_catalog.pg_class AS r2 JOIN pg_catalog.pg_namespace AS ns2 ON (r2.relnamespace=ns2.oid)
+ ) ON (c.confrelid=r2.oid)
+ LEFT JOIN pg_catalog.pg_attribute AS f2 ON
+ (f2.attrelid=r2.oid AND ((c.confkey[1]=f2.attnum AND c.conkey[1]=f1.attnum)';
+ for ($i = 2; $i <= $rs->fields['nb']; $i++)
+ $sql.= "OR (c.confkey[$i]=f2.attnum AND c.conkey[$i]=f1.attnum)";
+
+ $sql .= sprintf("))
+ WHERE
+ r1.relname = '%s' AND ns1.nspname='%s'
+ ORDER BY 1", $table, $this->_schema);
+
+ return $this->selectSet($sql);
}
/**
return $this->selectSet($sql);
}
- /**
- * Returns a list of all constraints on a table
- * @param $table The table to find rules for
- * @return A recordset
- */
- function getConstraints($table) {
- $this->clean($table);
-
- /* This query finds all foreign key and check constraints in the pg_constraint
- * table, and unions that with all indexes that are the basis for unique or
- * primary key constraints. */
- $sql = "
- SELECT conname, consrc, contype, indkey, indisclustered FROM (
- SELECT
- conname,
- CASE WHEN contype='f' THEN
- pg_catalog.pg_get_constraintdef(oid)
- ELSE
- 'CHECK (' || consrc || ')'
- END AS consrc,
- contype,
- conrelid AS relid,
- NULL AS indkey,
- FALSE AS indisclustered
- FROM
- pg_catalog.pg_constraint
- WHERE
- contype IN ('f', 'c')
- UNION ALL
- SELECT
- pc.relname,
- NULL,
- CASE WHEN indisprimary THEN
- 'p'
- ELSE
- 'u'
- END,
- pi.indrelid,
- indkey,
- pi.indisclustered
- FROM
- pg_catalog.pg_class pc,
- pg_catalog.pg_index pi
- WHERE
- pc.oid=pi.indexrelid
- AND EXISTS (
- SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c
- ON (d.refclassid = c.tableoid AND d.refobjid = c.oid)
- WHERE d.classid = pc.tableoid AND d.objid = pc.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p')
- )
- ) AS sub
- WHERE relid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'
- AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace
- WHERE nspname='{$this->_schema}'))
- ORDER BY
- 1
- ";
-
- return $this->selectSet($sql);
- }
-
/**
* Removes a constraint from a relation
* @param $constraint The constraint to drop
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres74.php,v 1.57 2007/03/28 18:52:34 soranzo Exp $
+ * $Id: Postgres74.php,v 1.58 2007/08/31 18:30:11 ioguix Exp $
*/
include_once('./classes/database/Postgres73.php');
return $this->selectSet($sql);
}
- // Constraint functions
-
- /**
- * Returns a list of all constraints on a table
- * @param $table The table to find rules for
- * @return A recordset
- */
- function getConstraints($table) {
- $this->clean($table);
-
- // This SQL is greatly complicated by the need to retrieve
- // index clustering information for primary and unique constraints
- $sql = "SELECT
- pc.conname,
- pg_catalog.pg_get_constraintdef(pc.oid, true) AS consrc,
- pc.contype,
- CASE WHEN pc.contype='u' OR pc.contype='p' THEN (
- SELECT
- indisclustered
- FROM
- pg_catalog.pg_depend pd,
- pg_catalog.pg_class pl,
- pg_catalog.pg_index pi
- WHERE
- pd.refclassid=pc.tableoid
- AND pd.refobjid=pc.oid
- AND pd.objid=pl.oid
- AND pl.oid=pi.indexrelid
- ) ELSE
- NULL
- END AS indisclustered
- FROM
- pg_catalog.pg_constraint pc
- WHERE
- pc.conrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'
- AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace
- WHERE nspname='{$this->_schema}'))
- ORDER BY
- 1
- ";
-
- return $this->selectSet($sql);
- }
-
// Administration functions
/**
$column = array(
'column' => array(
'title' => $lang['strcolumn'],
- 'field' => 'attname',
+ 'field' => field('attname'),
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => '+type',
+ 'field' => field('+type'),
)
);
if ($isTable) {
$column['notnull'] = array(
'title' => $lang['strnotnull'],
- 'field' => 'attnotnull',
+ 'field' => field('attnotnull'),
'type' => 'bool',
'params'=> array('true' => 'NOT NULL', 'false' => '')
);
$column['default'] = array(
'title' => $lang['strdefault'],
- 'field' => 'adsrc'
+ 'field' => field('adsrc'),
);
}
/**
* List constraints on a table
*
- * $Id: constraints.php,v 1.51 2007/07/16 21:27:28 ioguix Exp $
+ * $Id: constraints.php,v 1.52 2007/08/31 18:30:10 ioguix Exp $
*/
// Include application functions
$columns = array(
'constraint' => array(
'title' => $lang['strname'],
- 'field' => 'conname',
+ 'field' => field('conname'),
),
'definition' => array(
'title' => $lang['strdefinition'],
- 'field' => '+definition',
+ 'field' => field('+definition'),
'type' => 'pre',
),
'actions' => array(
/**
* Manage conversions in a database
*
- * $Id: conversions.php,v 1.14 2007/07/12 19:26:22 xzilla Exp $
+ * $Id: conversions.php,v 1.15 2007/08/31 18:30:10 ioguix Exp $
*/
// Include application functions
$columns = array(
'conversion' => array(
'title' => $lang['strname'],
- 'field' => 'conname',
+ 'field' => field('conname'),
),
'source_encoding' => array(
'title' => $lang['strsourceencoding'],
- 'field' => 'conforencoding',
+ 'field' => field('conforencoding'),
),
'target_encoding' => array(
'title' => $lang['strtargetencoding'],
- 'field' => 'contoencoding',
+ 'field' => field('contoencoding'),
),
'default' => array(
'title' => $lang['strdefault'],
- 'field' => 'condefault',
+ 'field' => field('condefault'),
'type' => 'yesno',
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'concomment',
+ 'field' => field('concomment'),
),
);
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.100 2007/07/16 21:27:28 ioguix Exp $
+ * $Id: database.php,v 1.101 2007/08/31 18:30:10 ioguix Exp $
*/
// Include application functions
$columns = array(
'variable' => array(
'title' => $lang['strname'],
- 'field' => 'name',
+ 'field' => field('name'),
),
'value' => array(
'title' => $lang['strsetting'],
- 'field' => 'setting',
+ 'field' => field('setting'),
),
);
$columns = array(
'transaction' => array(
'title' => $lang['strxactid'],
- 'field' => 'transaction',
+ 'field' => field('transaction'),
),
'gid' => array(
'title' => $lang['strgid'],
- 'field' => 'gid',
+ 'field' => field('gid'),
),
'prepared' => array(
'title' => $lang['strstarttime'],
- 'field' => 'prepared',
+ 'field' => field('prepared'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'owner',
+ 'field' => field('owner'),
),
);
$columns = array(
'user' => array(
'title' => $lang['strusername'],
- 'field' => 'usename',
+ 'field' => field('usename'),
),
'process' => array(
'title' => $lang['strprocess'],
- 'field' => 'procpid',
+ 'field' => field('procpid'),
),
'query' => array(
'title' => $lang['strsql'],
- 'field' => 'current_query',
+ 'field' => field('current_query'),
),
'start_time' => array(
'title' => $lang['strstarttime'],
- 'field' => 'query_start',
+ 'field' => field('query_start'),
),
);
$columns = array(
'namespace' => array(
'title' => $lang['strschema'],
- 'field' => 'nspname',
+ 'field' => field('nspname'),
),
'tablename' => array(
'title' => $lang['strtablename'],
- 'field' => 'tablename',
+ 'field' => field('tablename'),
),
'transactionid' => array(
'title' => $lang['strtransaction'],
- 'field' => 'transaction',
+ 'field' => field('transaction'),
),
'processid' => array(
'title' => $lang['strprocessid'],
- 'field' => 'pid',
+ 'field' => field('pid'),
),
'mode' => array(
'title' => $lang['strmode'],
- 'field' => 'mode',
+ 'field' => field('mode'),
),
'granted' => array(
'title' => $lang['strislockheld'],
- 'field' => 'granted',
+ 'field' => field('granted'),
'type' => 'yesno',
),
);
$columns = array(
'namespace' => array(
'title' => $lang['strschema'],
- 'field' => 'nspname',
+ 'field' => field('nspname'),
),
'relname' => array(
'title' => $lang['strtable'],
- 'field' => 'relname',
+ 'field' => field('relname'),
),
'enabled' => array(
'title' => $lang['strenabled'],
- 'field' => 'enabled',
+ 'field' => field('enabled'),
),
'vac_base_thresh' => array(
'title' => $lang['strvacuumbasethreshold'],
- 'field' => 'vac_base_thresh',
+ 'field' => field('vac_base_thresh'),
),
'vac_scale_factor' => array(
'title' => $lang['strvacuumscalefactor'],
- 'field' => 'vac_scale_factor',
+ 'field' => field('vac_scale_factor'),
),
'anl_base_thresh' => array(
'title' => $lang['stranalybasethreshold'],
- 'field' => 'anl_base_thresh',
+ 'field' => field('anl_base_thresh'),
),
'anl_scale_factor' => array(
'title' => $lang['stranalyzescalefactor'],
- 'field' => 'anl_scale_factor',
+ 'field' => field('anl_scale_factor'),
),
'vac_cost_delay' => array(
'title' => $lang['strvacuumcostdelay'],
- 'field' => 'vac_cost_delay',
+ 'field' => field('vac_cost_delay'),
),
'vac_cost_limit' => array(
'title' => $lang['strvacuumcostlimit'],
- 'field' => 'vac_cost_limit',
+ 'field' => field('vac_cost_limit'),
),
);
/**
* Manage domains in a database
*
- * $Id: domains.php,v 1.32 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: domains.php,v 1.33 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'domain' => array(
'title' => $lang['strdomain'],
- 'field' => 'domname',
+ 'field' => field('domname'),
'url' => "domains.php?action=properties&{$misc->href}&",
'vars' => array('domain' => 'domname'),
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => 'domtype',
+ 'field' => field('domtype'),
),
'notnull' => array(
'title' => $lang['strnotnull'],
- 'field' => 'domnotnull',
+ 'field' => field('domnotnull'),
'type' => 'bool',
'params'=> array('true' => 'NOT NULL', 'false' => ''),
),
'default' => array(
'title' => $lang['strdefault'],
- 'field' => 'domdef',
+ 'field' => field('domdef'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'domowner',
+ 'field' => field('domowner'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'domcomment',
+ 'field' => field('domcomment'),
),
);
/**
* Manage functions in a database
*
- * $Id: functions.php,v 1.66 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: functions.php,v 1.67 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'function' => array(
'title' => $lang['strfunction'],
- 'field' => 'proproto',
+ 'field' => field('proproto'),
'type' => 'verbatim',
'url' => "redirect.php?subject=function&action=properties&{$misc->href}&",
'vars' => array('function' => 'proproto', 'function_oid' => 'prooid'),
),
'returns' => array(
'title' => $lang['strreturns'],
- 'field' => 'proreturns',
+ 'field' => field('proreturns'),
'type' => 'verbatim',
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'proowner',
+ 'field' => field('proowner'),
),
'proglanguage' => array(
'title' => $lang['strproglanguage'],
- 'field' => 'prolanguage',
+ 'field' => field('prolanguage'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'procomment',
+ 'field' => field('procomment'),
),
);
/**
* Manage groups in a database cluster
*
- * $Id: groups.php,v 1.26 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: groups.php,v 1.27 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'group' => array(
'title' => $lang['strgroup'],
- 'field' => 'groname',
+ 'field' => field('groname'),
'url' => "groups.php?action=properties&{$misc->href}&",
'vars' => array('group' => 'groname'),
),
/**
* List indexes on a table
*
- * $Id: indexes.php,v 1.43 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: indexes.php,v 1.44 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'index' => array(
'title' => $lang['strname'],
- 'field' => 'indname',
+ 'field' => field('indname'),
),
'definition' => array(
'title' => $lang['strdefinition'],
- 'field' => 'inddef',
+ 'field' => field('inddef'),
),
'constraints' => array(
'title' => $lang['strconstraints'],
- 'field' => '+constraints',
+ 'field' => field('+constraints'),
'type' => 'verbatim',
'params'=> array('align' => 'center'),
),
'clustered' => array(
'title' => $lang['strclustered'],
- 'field' => 'indisclustered',
+ 'field' => field('indisclustered'),
'type' => 'yesno',
),
'actions' => array(
/**
* Manage languages in a database
*
- * $Id: languages.php,v 1.12 2007/07/12 19:26:22 xzilla Exp $
+ * $Id: languages.php,v 1.13 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'language' => array(
'title' => $lang['strname'],
- 'field' => 'lanname',
+ 'field' => field('lanname'),
),
'trusted' => array(
'title' => $lang['strtrusted'],
- 'field' => 'lanpltrusted',
+ 'field' => field('lanpltrusted'),
'type' => 'yesno',
),
'function' => array(
'title' => $lang['strfunction'],
- 'field' => 'lanplcallf',
+ 'field' => field('lanplcallf'),
),
);
/**
* Manage opclasss in a database
*
- * $Id: opclasses.php,v 1.9 2005/11/25 08:49:08 jollytoad Exp $
+ * $Id: opclasses.php,v 1.10 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'accessmethod' => array(
'title' => $lang['straccessmethod'],
- 'field' => 'amname',
+ 'field' => field('amname'),
),
'opclass' => array(
'title' => $lang['strname'],
- 'field' => 'opcname',
+ 'field' => field('opcname'),
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => 'opcintype',
+ 'field' => field('opcintype'),
),
'default' => array(
'title' => $lang['strdefault'],
- 'field' => 'opcdefault',
+ 'field' => field('opcdefault'),
'type' => 'yesno',
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'opccomment',
+ 'field' => field('opccomment'),
),
);
/**
* Manage operators in a database
*
- * $Id: operators.php,v 1.28 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: operators.php,v 1.29 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'operator' => array(
'title' => $lang['stroperator'],
- 'field' => 'oprname',
+ 'field' => field('oprname'),
'url' => "operators.php?action=properties&{$misc->href}&",
'vars' => array('operator' => 'oprname', 'operator_oid' => 'oid'),
),
'leftarg' => array(
'title' => $lang['strleftarg'],
- 'field' => 'oprleftname',
+ 'field' => field('oprleftname'),
),
'rightarg' => array(
'title' => $lang['strrightarg'],
- 'field' => 'oprrightname',
+ 'field' => field('oprrightname'),
),
'returns' => array(
'title' => $lang['strreturns'],
- 'field' => 'resultname',
+ 'field' => field('resultname'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'oprcomment',
+ 'field' => field('oprcomment'),
),
);
/**
* Slony database tab plugin
*
- * $Id: plugin_slony.php,v 1.22 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: plugin_slony.php,v 1.23 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'no_name' => array(
'title' => $lang['strcluster'],
- 'field' => 'cluster',
+ 'field' => field('cluster'),
'url' => "plugin_slony.php?{$misc->href}&action=cluster_properties&",
'vars' => array('slony_cluster' => 'cluster'),
),
),
'no_comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'comment',
+ 'field' => field('comment'),
)
);
$columns = array(
'no_name' => array(
'title' => $lang['strname'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
'url' => "plugin_slony.php?{$misc->href}&action=node_properties&subject=slony_node&",
'vars' => array('no_id' => 'no_id', 'no_name' => 'no_comment'),
),
'no_status' => array(
'title' => $lang['strstatus'],
- 'field' => 'no_status',
+ 'field' => field('no_status'),
'type' => 'slonystatus',
),
'actions' => array(
),
'no_comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
)
);
$columns = array(
'no_name' => array(
'title' => $lang['strname'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
'url' => "plugin_slony.php?{$misc->href}&action=path_properties&",
'vars' => array('no_id' => 'pa_client', 'path_id' => 'no_id'),
),
),
'no_comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
)
);
$columns = array(
'no_name' => array(
'title' => $lang['strname'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
'url' => "plugin_slony.php?{$misc->href}&action=listen_properties&",
'vars' => array('no_id' => 'li_receiver', 'listen_id' => 'no_id', 'origin_id' => 'li_origin'),
),
),
'no_comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
)
);
$columns = array(
'set_name' => array(
'title' => $lang['strname'],
- 'field' => 'set_comment',
+ 'field' => field('set_comment'),
'url' => "plugin_slony.php?{$misc->href}&action=set_properties&",
'vars' => array('set_id' => 'set_id'),
),
),
'set_comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'set_comment',
+ 'field' => field('set_comment'),
)
);
$columns = array(
'table' => array(
'title' => $lang['strtable'],
- 'field' => 'qualname',
+ 'field' => field('qualname'),
'url' => "redirect.php?subject=table&{$misc->href}&",
'vars' => array('table' => 'relname', 'schema' => 'nspname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'relowner',
+ 'field' => field('relowner'),
),
'tablespace' => array(
'title' => $lang['strtablespace'],
- 'field' => 'tablespace',
+ 'field' => field('tablespace'),
),
'tuples' => array(
'title' => $lang['strestimatedrowcount'],
- 'field' => 'reltuples',
+ 'field' => field('reltuples'),
'type' => 'numeric',
),
'actions' => array(
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'relcomment',
+ 'field' => field('relcomment'),
),
);
$columns = array(
'sequence' => array(
'title' => $lang['strsequence'],
- 'field' => 'qualname',
+ 'field' => field('qualname'),
'url' => "sequences.php?action=properties&{$misc->href}&",
'vars' => array('sequence' => 'seqname', 'schema' => 'nspname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'seqowner',
+ 'field' => field('seqowner'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'seqcomment',
+ 'field' => field('seqcomment'),
),
);
$columns = array(
'no_name' => array(
'title' => $lang['strname'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
'url' => "plugin_slony.php?{$misc->href}&action=subscription_properties&",
'vars' => array('set_id' => 'sub_set', 'no_id' => 'no_id'),
),
'no_comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'no_comment',
+ 'field' => field('no_comment'),
)
);
/**
* List reports in a database
*
- * $Id: reports.php,v 1.31 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: reports.php,v 1.32 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'report' => array(
'title' => $lang['strreport'],
- 'field' => 'report_name',
+ 'field' => field('report_name'),
'url' => "reports.php?action=properties&{$misc->href}&",
'vars' => array('report_id' => 'report_id'),
),
'database' => array(
'title' => $lang['strdatabase'],
- 'field' => 'db_name',
+ 'field' => field('db_name'),
),
'created' => array(
'title' => $lang['strcreated'],
- 'field' => 'date_created',
+ 'field' => field('date_created'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'descr',
+ 'field' => field('descr'),
),
);
/**
* Manage roles in a database cluster
*
- * $Id: roles.php,v 1.9 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: roles.php,v 1.10 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'role' => array(
'title' => $lang['strrole'],
- 'field' => 'rolname',
+ 'field' => field('rolname'),
'url' => "redirect.php?subject=role&action=properties&{$misc->href}&",
'vars' => array('rolename' => 'rolname'),
),
'superuser' => array(
'title' => $lang['strsuper'],
- 'field' => 'rolsuper',
+ 'field' => field('rolsuper'),
'type' => 'yesno',
),
'createdb' => array(
'title' => $lang['strcreatedb'],
- 'field' => 'rolcreatedb',
+ 'field' => field('rolcreatedb'),
'type' => 'yesno',
),
'createrole' => array(
'title' => $lang['strcancreaterole'],
- 'field' => 'rolcreaterole',
+ 'field' => field('rolcreaterole'),
'type' => 'yesno',
),
'inherits' => array(
'title' => $lang['strinheritsprivs'],
- 'field' => 'rolinherit',
+ 'field' => field('rolinherit'),
'type' => 'yesno',
),
'canloging' => array(
'title' => $lang['strcanlogin'],
- 'field' => 'rolcanlogin',
+ 'field' => field('rolcanlogin'),
'type' => 'yesno',
),
'connlimit' => array(
'title' => $lang['strconnlimit'],
- 'field' => 'rolconnlimit',
+ 'field' => field('rolconnlimit'),
'type' => 'callback',
'params'=> array('function' => 'renderRoleConnLimit')
),
'expires' => array(
'title' => $lang['strexpires'],
- 'field' => 'rolvaliduntil',
+ 'field' => field('rolvaliduntil'),
'type' => 'callback',
'params'=> array('function' => 'renderRoleExpires', 'null' => $lang['strnever']),
),
/**
* List rules on a table OR view
*
- * $Id: rules.php,v 1.32 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: rules.php,v 1.33 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'rule' => array(
'title' => $lang['strname'],
- 'field' => 'rulename',
+ 'field' => field('rulename'),
),
'definition' => array(
'title' => $lang['strdefinition'],
- 'field' => 'definition',
+ 'field' => field('definition'),
),
'actions' => array(
'title' => $lang['stractions'],
/**
* Manage schemas in a database
*
- * $Id: schemas.php,v 1.18 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: schemas.php,v 1.19 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'schema' => array(
'title' => $lang['strschema'],
- 'field' => 'nspname',
+ 'field' => field('nspname'),
'url' => "redirect.php?subject=schema&{$misc->href}&",
'vars' => array('schema' => 'nspname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'nspowner',
+ 'field' => field('nspowner'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'nspcomment',
+ 'field' => field('nspcomment'),
),
);
/**
* Manage sequences in a database
*
- * $Id: sequences.php,v 1.42 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: sequences.php,v 1.43 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'sequence' => array(
'title' => $lang['strsequence'],
- 'field' => 'seqname',
+ 'field' => field('seqname'),
'url' => "sequences.php?action=properties&{$misc->href}&",
'vars' => array('sequence' => 'seqname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'seqowner',
+ 'field' => field('seqowner'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'seqcomment',
+ 'field' => field('seqcomment'),
),
);
/**
* Manage servers
*
- * $Id: servers.php,v 1.10 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: servers.php,v 1.11 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'server' => array(
'title' => $lang['strserver'],
- 'field' => 'desc',
+ 'field' => field('desc'),
'url' => "redirect.php?subject=server&",
'vars' => array('server' => 'id'),
),
'host' => array(
'title' => $lang['strhost'],
- 'field' => 'host',
+ 'field' => field('host'),
),
'port' => array(
'title' => $lang['strport'],
- 'field' => 'port',
+ 'field' => field('port'),
),
'username' => array(
'title' => $lang['strusername'],
- 'field' => 'username',
+ 'field' => field('username'),
),
'actions' => array(
'title' => $lang['stractions'],
/**
* List tables in a database
*
- * $Id: tables.php,v 1.100 2007/07/17 14:59:52 ioguix Exp $
+ * $Id: tables.php,v 1.101 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'table' => array(
'title' => $lang['strtable'],
- 'field' => 'relname',
+ 'field' => field('relname'),
'url' => "redirect.php?subject=table&{$misc->href}&",
'vars' => array('table' => 'relname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'relowner',
+ 'field' => field('relowner'),
),
'tablespace' => array(
'title' => $lang['strtablespace'],
- 'field' => 'tablespace'
+ 'field' => field('tablespace')
),
'tuples' => array(
'title' => $lang['strestimatedrowcount'],
- 'field' => 'reltuples',
+ 'field' => field('reltuples'),
'type' => 'numeric'
),
'actions' => array(
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'relcomment',
+ 'field' => field('relcomment'),
),
);
/**
* Manage tablespaces in a database cluster
*
- * $Id: tablespaces.php,v 1.15 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: tablespaces.php,v 1.16 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'database' => array(
'title' => $lang['strname'],
- 'field' => 'spcname'
+ 'field' => field('spcname')
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'spcowner'
+ 'field' => field('spcowner')
),
'location' => array(
'title' => $lang['strlocation'],
- 'field' => 'spclocation'
+ 'field' => field('spclocation')
),
'actions' => array(
'title' => $lang['stractions']
if ($data->hasSharedComments()) {
$columns['comment'] = array(
'title' => $lang['strcomment'],
- 'field' => 'spccomment',
+ 'field' => field('spccomment'),
);
}
/**
* List tables in a database
*
- * $Id: tblproperties.php,v 1.83 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: tblproperties.php,v 1.84 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
function attPre(&$rowdata, $actions) {
global $data;
$rowdata->fields['+type'] = $data->formatType($rowdata->fields['type'], $rowdata->fields['atttypmod']);
- $actions['browse']['url'] .= "query=" . urlencode("SELECT \"{$rowdata->fields['attname']}\", count(*) AS \"count\" FROM \"{$_REQUEST['table']}\" GROUP BY \"{$rowdata->fields['attname']}\" ORDER BY \"{$rowdata->fields['attname']}\"") . '&';
+ $actions['browse']['url'] .= 'query=' . urlencode("SELECT \"{$rowdata->fields['attname']}\", count(*) AS \"count\" FROM \"{$_REQUEST['table']}\" GROUP BY \"{$rowdata->fields['attname']}\" ORDER BY \"{$rowdata->fields['attname']}\"") . '&';
return $actions;
}
-
+
$misc->printTrail('table');
$misc->printTabs('table','columns');
$misc->printMsg($msg);
$tdata = $data->getTable($_REQUEST['table']);
// Get columns
$attrs = $data->getTableAttributes($_REQUEST['table']);
+ // Get Pk & Constraints
+ $ck = $data->getConstraints($_REQUEST['table']);
// Show comment if any
if ($tdata->fields['relcomment'] !== null)
- echo "<p class=\"comment\">", $misc->printVal($tdata->fields['relcomment']), "</p>\n";
+ echo '<p class="comment">', $misc->printVal($tdata->fields['relcomment']), "</p>\n";
$columns = array(
'column' => array(
'title' => $lang['strcolumn'],
- 'field' => 'attname',
+ 'field' => field('attname'),
'url' => "colproperties.php?subject=column&{$misc->href}&table=".urlencode($_REQUEST['table'])."&",
'vars' => array('column' => 'attname'),
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => '+type',
+ 'field' => field('+type'),
),
'notnull' => array(
'title' => $lang['strnotnull'],
- 'field' => 'attnotnull',
+ 'field' => field('attnotnull'),
'type' => 'bool',
'params'=> array('true' => 'NOT NULL', 'false' => ''),
),
'default' => array(
'title' => $lang['strdefault'],
- 'field' => 'adsrc',
+ 'field' => field('adsrc'),
+ ),
+ 'keyprop' => array(
+ 'title' => $lang['strconstraints'],
+ 'field' => field('attname'),
+ 'type' => 'callback',
+ 'params'=> array(
+ 'function' => 'cstrRender',
+ 'keys' => $ck->getArray()
+ ),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'comment',
+ 'field' => field('comment'),
),
);
+ if (!$data->hasForeignKeysInfo()) {
+ unset($columns['keyprop']);
+ }
+ else {
+ function cstrRender($s, $p) {
+ global $misc;
+
+ $str ='';
+ foreach ($p['keys'] as $c)
+ if ($c['p_field'] == $s)
+ switch ($c['contype']) {
+ case 'p':
+ $str .= '<a href="constraints.php?'. $misc->href ."&table={$c['p_table']}&schema={$c['p_schema']}\"><img src=\"".
+ $misc->icon('PrimaryKey') .'" alt="[pk]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ break;
+ case 'f':
+ $str .= '<a href="tblproperties.php?'. $misc->href ."&table={$c['f_table']}&schema={$c['f_schema']}\"><img src=\"".
+ $misc->icon('ForeignKey') .'" alt="[fk]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ break;
+ case 'u':
+ $str .= '<a href="constraints.php?'. $misc->href ."&table={$c['p_table']}&schema={$c['p_schema']}\"><img src=\"".
+ $misc->icon('UniqueConstraint') .'" alt="[uniq]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ break;
+ case 'c':
+ $str .= '<a href="constraints.php?'. $misc->href ."&table={$c['p_table']}&schema={$c['p_schema']}\"><img src=\"".
+ $misc->icon('CheckConstraint') .'" alt="[check]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ }
+
+ return $str;
+ }
+ }
$return_url = urlencode("tblproperties.php?{$misc->href}&table={$_REQUEST['table']}");
/**
* List triggers on a table
*
- * $Id: triggers.php,v 1.35 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: triggers.php,v 1.36 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'trigger' => array(
'title' => $lang['strname'],
- 'field' => 'tgname',
+ 'field' => field('tgname'),
),
'definition' => array(
'title' => $lang['strdefinition'],
- 'field' => '+tgdef',
+ 'field' => field('+tgdef'),
),
'actions' => array(
'title' => $lang['stractions'],
/**
* Manage types in a database
*
- * $Id: types.php,v 1.38 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: types.php,v 1.39 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'field' => array(
'title' => $lang['strfield'],
- 'field' => 'attname',
+ 'field' => field('attname'),
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => '+type',
+ 'field' => field('+type'),
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'comment',
+ 'field' => field('comment'),
)
);
$columns = array(
'type' => array(
'title' => $lang['strtype'],
- 'field' => 'typname',
+ 'field' => field('typname'),
'url' => "types.php?action=properties&{$misc->href}&",
'vars' => array('type' => 'basename'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'typowner',
+ 'field' => field('typowner'),
),
'flavour' => array(
'title' => $lang['strflavor'],
- 'field' => 'typtype',
+ 'field' => field('typtype'),
'type' => 'verbatim',
'params'=> array(
'map' => array(
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'typcomment',
+ 'field' => field('typcomment'),
),
);
/**
* Manage users in a database cluster
*
- * $Id: users.php,v 1.38 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: users.php,v 1.39 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'user' => array(
'title' => $lang['strusername'],
- 'field' => 'usename',
+ 'field' => field('usename'),
),
'superuser' => array(
'title' => $lang['strsuper'],
- 'field' => 'usesuper',
+ 'field' => field('usesuper'),
'type' => 'yesno',
),
'createdb' => array(
'title' => $lang['strcreatedb'],
- 'field' => 'usecreatedb',
+ 'field' => field('usecreatedb'),
'type' => 'yesno',
),
'expires' => array(
'title' => $lang['strexpires'],
- 'field' => 'useexpires',
+ 'field' => field('useexpires'),
'type' => 'callback',
'params'=> array('function' => 'renderUseExpires', 'null' => $lang['strnever']),
),
'defaults' => array(
'title' => $lang['strsessiondefaults'],
- 'field' => 'useconfig',
+ 'field' => field('useconfig'),
),
'actions' => array(
'title' => $lang['stractions'],
/**
* List views in a database
*
- * $Id: viewproperties.php,v 1.30 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: viewproperties.php,v 1.31 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'column' => array(
'title' => $lang['strcolumn'],
- 'field' => 'attname',
+ 'field' => field('attname'),
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => '+type',
+ 'field' => field('+type'),
),
'default' => array(
'title' => $lang['strdefault'],
- 'field' => 'adsrc',
+ 'field' => field('adsrc'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'comment',
+ 'field' => field('comment'),
),
);
/**
* Manage views in a database
*
- * $Id: views.php,v 1.72 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: views.php,v 1.73 2007/08/31 18:30:11 ioguix Exp $
*/
// Include application functions
$columns = array(
'view' => array(
'title' => $lang['strview'],
- 'field' => 'relname',
+ 'field' => field('relname'),
'url' => "redirect.php?subject=view&{$misc->href}&",
'vars' => array('view' => 'relname'),
),
'owner' => array(
'title' => $lang['strowner'],
- 'field' => 'relowner',
+ 'field' => field('relowner'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'comment' => array(
'title' => $lang['strcomment'],
- 'field' => 'relcomment',
+ 'field' => field('relcomment'),
),
);