|
| listTables () |
|
| describeTable ($tableName, $schemaName=null) |
|
| limit ($sql, $count, $offset=0) |
|
| lastInsertId ($tableName=null, $primaryKey=null) |
|
| getServerVersion () |
|
| 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 Mssql.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 PRIMARY_AUTO => integer; position of auto-generated column in primary key
- Todo:
Discover column primary key position.
Discover integer unsigned property.
- Parameters
-
string | $tableName | |
string | $schemaName | OPTIONAL |
- Returns
- array
Discover metadata information about this table.
Discover primary key column(s) for this table.
Definition at line 221 of file Mssql.php.
223 if ($schemaName !=
null) {
224 if (strpos($schemaName,
'.') !==
false) {
225 $result = explode(
'.', $schemaName);
233 if ($schemaName !=
null) {
234 $sql .=
", @table_owner = " . $this->
quoteIdentifier($schemaName,
true);
237 $stmt = $this->
query($sql);
248 $column_position = 16;
254 if ($schemaName !=
null) {
255 $sql .=
", @table_owner = " . $this->
quoteIdentifier($schemaName,
true);
258 $stmt = $this->
query($sql);
260 $primaryKeyColumn = array();
261 $pkey_column_name = 3;
263 foreach ($primaryKeysResult as $pkeysRow) {
264 $primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
271 $words = explode(
' ',
$row[$type_name], 2);
272 if (isset($words[0])) {
274 if (isset($words[1])) {
275 $identity = (bool) preg_match(
'/identity/', $words[1]);
279 $isPrimary = array_key_exists(
$row[$column_name], $primaryKeyColumn);
281 $primaryPosition = $primaryKeyColumn[
$row[$column_name]];
283 $primaryPosition =
null;
287 'SCHEMA_NAME' =>
null,
290 'COLUMN_POSITION' => (
int)
$row[$column_position],
291 'DATA_TYPE' =>
$type,
292 'DEFAULT' =>
$row[$column_def],
293 'NULLABLE' => (
bool)
$row[$nullable],
294 'LENGTH' =>
$row[$length],
295 'SCALE' =>
$row[$scale],
296 'PRECISION' =>
$row[$precision],
298 'PRIMARY' => $isPrimary,
299 'PRIMARY_POSITION' => $primaryPosition,
300 'IDENTITY' => $identity
quoteIdentifier($ident, $auto=false)
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.
Microsoft SQL Server does not support sequences, so the arguments to this method are ignored.
- Parameters
-
string | $tableName | OPTIONAL Name of table. |
string | $primaryKey | OPTIONAL Name of primary key column. |
- Returns
- string
- Exceptions
-
Definition at line 399 of file Mssql.php.
401 $sql =
'SELECT SCOPE_IDENTITY()';
fetchOne($sql, $bind=array())