Definition at line 57 of file pgsql.php.
◆ getTableConstraintDefinition()
MDB2_Driver_Reverse_pgsql::getTableConstraintDefinition |
( |
|
$table, |
|
|
|
$constraint_name |
|
) |
| |
Get the structure of a constraint into an array.
- Parameters
-
string | $table | name of table that should be used in method |
string | $constraint_name | name of constraint that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 246 of file pgsql.php.
References $columns, $query, $row, $table, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, and MDB2_FETCHMODE_ASSOC.
253 $query =
'SELECT relname, indisunique, indisprimary, indkey FROM pg_index, pg_class';
254 $query.=
' WHERE pg_class.oid = pg_index.indexrelid';
255 $query.=
" AND (indisunique = 't' OR indisprimary = 't')";
256 $query.=
' AND pg_class.relname = %s';
257 $constraint_name_mdb2 = $db->getIndexName($constraint_name);
269 $constraint_name .
' is not an existing table constraint', __FUNCTION__);
272 $row = array_change_key_case(
$row, CASE_LOWER);
274 $db->loadModule(
'Manager', null,
true);
277 $definition =
array();
278 if (
$row[
'indisprimary'] ==
't') {
279 $definition[
'primary'] =
true;
280 } elseif (
$row[
'indisunique'] ==
't') {
281 $definition[
'unique'] =
true;
284 $index_column_numbers = explode(
' ',
$row[
'indkey']);
287 foreach ($index_column_numbers as $number) {
289 'position' => $colpos++,
290 'sorting' =>
'ascending',
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
const MDB2_ERROR_NOT_FOUND
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
if(empty($password)) $table
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ getTableFieldDefinition()
MDB2_Driver_Reverse_pgsql::getTableFieldDefinition |
( |
|
$table, |
|
|
|
$field_name |
|
) |
| |
Get the structure of a field into an array.
- Parameters
-
string | $table | name of table that should be used in method |
string | $field_name | name of field that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 69 of file pgsql.php.
References $column, $key, $query, $result, $table, $type, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, and MDB2_FETCHMODE_ASSOC.
76 $result = $db->loadModule(
'Datatype', null,
true);
81 $query =
"SELECT a.attname AS name, 86 WHEN 'numeric' THEN (a.atttypmod / 65536) 87 WHEN 'decimal' THEN (a.atttypmod / 65536) 88 WHEN 'money' THEN (a.atttypmod / 65536) 97 WHEN 'numeric' THEN (a.atttypmod % 65536) - 4 98 WHEN 'decimal' THEN (a.atttypmod % 65536) - 4 99 WHEN 'money' THEN (a.atttypmod % 65536) - 4 105 (SELECT substring(pg_get_expr(d.adbin, d.adrelid) for 128) 107 WHERE d.adrelid = a.attrelid 108 AND d.adnum = a.attnum 114 WHERE c.relname = ".$db->quote(
$table,
'text').
" 115 AND a.atttypid = t.oid 116 AND c.oid = a.attrelid 117 AND NOT a.attisdropped 119 AND a.attname = ".$db->quote($field_name,
'text').
" 128 'it was not specified an existing table column', __FUNCTION__);
132 $mapped_datatype = $db->datatype->mapNativeDatatype(
$column);
133 if (PEAR::IsError($mapped_datatype)) {
134 return $mapped_datatype;
136 list($types, $length, $unsigned, $fixed) = $mapped_datatype;
138 if (!empty(
$column[
'attnotnull']) &&
$column[
'attnotnull'] ==
't') {
142 if (
$column[
'atthasdef'] ===
't' 143 && !preg_match(
"/nextval\('([^']+)'/",
$column[
'default'])
146 if (is_null($default) && $notnull) {
150 $autoincrement =
false;
151 if (preg_match(
"/nextval\('([^']+)'/",
$column[
'default'], $nextvals)) {
152 $autoincrement =
true;
154 $definition[0] =
array(
'notnull' => $notnull,
'nativetype' =>
$column[
'type']);
155 if (!is_null($length)) {
156 $definition[0][
'length'] = $length;
158 if (!is_null($unsigned)) {
159 $definition[0][
'unsigned'] = $unsigned;
161 if (!is_null($fixed)) {
162 $definition[0][
'fixed'] = $fixed;
164 if ($default !==
false) {
165 $definition[0][
'default'] = $default;
167 if ($autoincrement !==
false) {
168 $definition[0][
'autoincrement'] = $autoincrement;
171 $definition[
$key] = $definition[0];
173 unset($definition[
$key][
'default']);
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
const MDB2_ERROR_NOT_FOUND
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
if(empty($password)) $table
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ getTableIndexDefinition()
MDB2_Driver_Reverse_pgsql::getTableIndexDefinition |
( |
|
$table, |
|
|
|
$index_name |
|
) |
| |
Get the structure of an index into an array.
- Parameters
-
string | $table | name of table that should be used in method |
string | $index_name | name of index that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 191 of file pgsql.php.
References $columns, $query, $row, $table, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, and MDB2_FETCHMODE_ASSOC.
198 $query =
'SELECT relname, indkey FROM pg_index, pg_class';
199 $query.=
' WHERE pg_class.oid = pg_index.indexrelid';
200 $query.=
" AND indisunique != 't' AND indisprimary != 't'";
201 $query.=
' AND pg_class.relname = %s';
202 $index_name_mdb2 = $db->getIndexName($index_name);
214 'it was not specified an existing table index', __FUNCTION__);
217 $row = array_change_key_case(
$row, CASE_LOWER);
219 $db->loadModule(
'Manager', null,
true);
222 $definition =
array();
224 $index_column_numbers = explode(
' ',
$row[
'indkey']);
227 foreach ($index_column_numbers as $number) {
229 'position' => $colpos++,
230 'sorting' =>
'ascending',
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
const MDB2_ERROR_NOT_FOUND
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
if(empty($password)) $table
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ getTriggerDefinition()
MDB2_Driver_Reverse_pgsql::getTriggerDefinition |
( |
|
$trigger | ) |
|
Get the structure of a trigger into an array.
EXPERIMENTAL
WARNING: this function is experimental and may change the returned value at any time until labelled as non-experimental
- Parameters
-
string | $trigger | name of trigger that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
: add support for plsql functions and functions with args
Definition at line 313 of file pgsql.php.
References $query, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_FETCHMODE_ASSOC.
320 $query =
"SELECT trg.tgname AS trigger_name, 321 tbl.relname AS table_name, 323 WHEN p.proname IS NOT NULL THEN 'EXECUTE PROCEDURE ' || p.proname || '();' 326 CASE trg.tgtype & cast(2 as int2) 330 CASE trg.tgtype & cast(28 as int2) 331 WHEN 16 THEN 'UPDATE' 334 WHEN 20 THEN 'INSERT, UPDATE' 335 WHEN 28 THEN 'INSERT, UPDATE, DELETE' 336 WHEN 24 THEN 'UPDATE, DELETE' 337 WHEN 12 THEN 'INSERT, DELETE' 338 END AS trigger_event, 339 trg.tgenabled AS trigger_enabled, 340 obj_description(trg.oid, 'pg_trigger') AS trigger_comment 344 WHERE trg.tgrelid = tbl.oid 345 AND trg.tgfoid = p.oid 346 AND trg.tgname = ". $db->quote($trigger,
'text');
348 'trigger_name' =>
'text',
349 'table_name' =>
'text',
350 'trigger_body' =>
'text',
351 'trigger_type' =>
'text',
352 'trigger_event' =>
'text',
353 'trigger_comment' =>
'text',
354 'trigger_enabled' =>
'boolean',
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ tableInfo()
MDB2_Driver_Reverse_pgsql::tableInfo |
( |
|
$result, |
|
|
|
$mode = null |
|
) |
| |
Returns information about a table or a result set.
NOTE: only supports 'table' and 'flags' if $result is a table name.
- Parameters
-
object | string | $result | MDB2_result object from a query or a string containing the name of a table. While this also accepts a query result resource identifier, this behavior is deprecated. |
int | $mode | a valid tableInfo mode |
- Returns
- array an associative array with the information requested. A MDB2_Error object on failure.
- See also
- MDB2_Driver_Common::tableInfo()
Definition at line 380 of file pgsql.php.
References $i, $res, $result, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2\isResultCommon(), MDB2_ERROR_NEED_MORE_DATA, MDB2_PORTABILITY_FIX_CASE, MDB2_TABLEINFO_ORDER, and MDB2_TABLEINFO_ORDERTABLE.
383 return parent::tableInfo(
$result, $mode);
392 if (!is_resource($resource)) {
394 'Could not generate result resource', __FUNCTION__);
398 if ($db->options[
'field_case'] == CASE_LOWER) {
399 $case_func =
'strtolower';
401 $case_func =
'strtoupper';
404 $case_func =
'strval';
407 $count = @pg_num_fields($resource);
411 $res[
'num_fields'] = $count;
414 $db->loadModule(
'Datatype', null,
true);
415 for (
$i = 0;
$i < $count;
$i++) {
417 'table' => function_exists(
'pg_field_table') ? @pg_field_table($resource,
$i) :
'',
418 'name' => $case_func(@pg_field_name($resource,
$i)),
419 'type' => @pg_field_type($resource,
$i),
420 'length' => @pg_field_size($resource,
$i),
423 $mdb2type_info = $db->datatype->mapNativeDatatype(
$res[
$i]);
425 return $mdb2type_info;
427 $res[
$i][
'mdb2type'] = $mdb2type_info[0][0];
const MDB2_TABLEINFO_ORDER
These are constants for the tableInfo-function they are bitwised or'ed.
foreach($_POST as $key=> $value) $res
const MDB2_TABLEINFO_ORDERTABLE
const MDB2_ERROR_NEED_MORE_DATA
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
isError($data, $code=null)
Tell whether a value is a PEAR error.
The documentation for this class was generated from the following file:
- Services/Database/lib/PEAR/MDB2/Driver/Reverse/pgsql.php