|
| listTables () |
|
| describeTable ($tableName, $schemaName=null) |
|
| limit ($sql, $count, $offset=0) |
|
| lastSequenceId ($sequenceName) |
|
| nextSequenceId ($sequenceName) |
|
| lastInsertId ($tableName=null, $primaryKey=null) |
|
| isConnected () |
|
| closeConnection () |
|
| prepare ($sql) |
|
| lastInsertId ($tableName=null, $primaryKey=null) |
|
| query ($sql, $bind=array()) |
|
| exec ($sql) |
|
| setFetchMode ($mode) |
|
| supportsParameters ($type) |
|
| getServerVersion () |
|
| __construct ($config) |
|
| getConnection () |
|
| getConfig () |
|
| setProfiler ($profiler) |
|
| getProfiler () |
|
| getStatementClass () |
|
| setStatementClass ($class) |
|
| query ($sql, $bind=array()) |
|
| beginTransaction () |
|
| commit () |
|
| rollBack () |
|
| insert ($table, array $bind) |
|
| update ($table, array $bind, $where='') |
|
| delete ($table, $where='') |
|
| select () |
|
| getFetchMode () |
|
| fetchAll ($sql, $bind=array(), $fetchMode=null) |
|
| fetchRow ($sql, $bind=array(), $fetchMode=null) |
|
| fetchAssoc ($sql, $bind=array()) |
|
| fetchCol ($sql, $bind=array()) |
|
| fetchPairs ($sql, $bind=array()) |
|
| fetchOne ($sql, $bind=array()) |
|
| quote ($value, $type=null) |
|
| quoteInto ($text, $value, $type=null, $count=null) |
|
| quoteIdentifier ($ident, $auto=false) |
|
| quoteColumnAs ($ident, $alias, $auto=false) |
|
| quoteTableAs ($ident, $alias=null, $auto=false) |
|
| getQuoteIdentifierSymbol () |
|
| lastSequenceId ($sequenceName) |
|
| nextSequenceId ($sequenceName) |
|
| foldCase ($key) |
|
| __sleep () |
|
| __wakeup () |
|
| listTables () |
|
| describeTable ($tableName, $schemaName=null) |
|
| isConnected () |
|
| closeConnection () |
|
| prepare ($sql) |
|
| lastInsertId ($tableName=null, $primaryKey=null) |
|
| setFetchMode ($mode) |
|
| limit ($sql, $count, $offset=0) |
|
| supportsParameters ($type) |
|
| getServerVersion () |
|
Definition at line 39 of file Pgsql.php.
describeTable |
( |
|
$tableName, |
|
|
|
$schemaName = null |
|
) |
| |
Returns the column descriptions for a table.
The return value is an associative array keyed by the column name, as returned by the RDBMS.
The value of each array element is an associative array with the following keys:
SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; COLUMN_NAME => string; column name COLUMN_POSITION => number; ordinal position of column in table DATA_TYPE => string; SQL datatype name of column DEFAULT => string; default expression of column, null if none NULLABLE => boolean; true if column can have nulls LENGTH => number; length of CHAR/VARCHAR SCALE => number; scale of NUMERIC/DECIMAL PRECISION => number; precision of NUMERIC/DECIMAL UNSIGNED => boolean; unsigned property of an integer type PRIMARY => boolean; true if column is part of the primary key PRIMARY_POSITION => integer; position of column in primary key IDENTITY => integer; true if column is auto-generated with unique values
- Todo:
- Discover integer unsigned property.
- Parameters
-
string | $tableName | |
string | $schemaName | OPTIONAL |
- Returns
- array
Definition at line 149 of file Pgsql.php.
155 a.attname AS colname, 158 FORMAT_TYPE(a.atttypid, a.atttypmod) AS complete_type, 159 d.adsrc AS default_value, 160 a.attnotnull AS notnull, 163 ARRAY_TO_STRING(co.conkey, ',') AS conkey 164 FROM pg_attribute AS a 165 JOIN pg_class AS c ON a.attrelid = c.oid 166 JOIN pg_namespace AS n ON c.relnamespace = n.oid 167 JOIN pg_type AS t ON a.atttypid = t.oid 168 LEFT OUTER JOIN pg_constraint AS co ON (co.conrelid = c.oid 169 AND a.attnum = ANY(co.conkey) AND co.contype = 'p') 170 LEFT OUTER JOIN pg_attrdef AS d ON d.adrelid = c.oid AND d.adnum = a.attnum 171 WHERE a.attnum > 0 AND c.relname = ".$this->quote(
$tableName);
173 $sql .=
" AND n.nspname = ".$this->quote($schemaName);
175 $sql .=
' ORDER BY a.attnum';
177 $stmt = $this->
query($sql);
197 $defaultValue =
$row[$default_value];
199 if (preg_match(
'/character(?: varying)?(?:\((\d+)\))?/',
$row[$complete_type], $matches)) {
200 if (isset($matches[1])) {
201 $row[$length] = $matches[1];
203 $row[$length] =
null;
206 if (preg_match(
"/^'(.*?)'::(?:character varying|bpchar)$/", $defaultValue, $matches)) {
207 $defaultValue = $matches[1];
210 list($primary, $primaryPosition, $identity) = array(
false,
null,
false);
211 if (
$row[$contype] ==
'p') {
213 $primaryPosition = array_search(
$row[$attnum], explode(
',',
$row[$conkey])) + 1;
214 $identity = (bool) (preg_match(
'/^nextval/',
$row[$default_value]));
220 'COLUMN_POSITION' =>
$row[$attnum],
222 'DEFAULT' => $defaultValue,
223 'NULLABLE' => (
bool) (
$row[$notnull] !=
't'),
224 'LENGTH' =>
$row[$length],
228 'PRIMARY' => $primary,
229 'PRIMARY_POSITION' => $primaryPosition,
230 'IDENTITY' => $identity
query($sql, $bind=array())
lastInsertId |
( |
|
$tableName = null , |
|
|
|
$primaryKey = null |
|
) |
| |
Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
As a convention, on RDBMS brands that support sequences (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence from the arguments and returns the last id generated by that sequence. On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method returns the last value generated for such a column, and the table name argument is disregarded.
- Parameters
-
string | $tableName | OPTIONAL Name of table. |
string | $primaryKey | OPTIONAL Name of primary key column. |
- Returns
- string
Definition at line 323 of file Pgsql.php.
328 $sequenceName .=
"_$primaryKey";
330 $sequenceName .=
'_seq';
333 return $this->_connection->lastInsertId(
$tableName);
lastSequenceId($sequenceName)