|
| getQuoteIdentifierSymbol () |
|
| listTables () |
|
| describeTable ($tableName, $schemaName=null) |
|
| isConnected () |
|
| closeConnection () |
|
| prepare ($sql) |
|
| lastInsertId ($tableName=null, $primaryKey=null) |
|
| setFetchMode ($mode) |
|
| limit ($sql, $count, $offset=0) |
|
| 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 52 of file Mysqli.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
- Parameters
-
string | $tableName | |
string | $schemaName | OPTIONAL |
- Returns
- array
- Todo:
- use INFORMATION_SCHEMA someday when MySQL's implementation isn't too slow.
Use mysqli extension API, because DESCRIBE doesn't work well as a prepared statement on MySQL 4.1.
- See also
- Zend_Db_Adapter_Mysqli_Exception
The optional argument of a MySQL int type is not precision or length; it is only a hint for display width.
Definition at line 177 of file Mysqli.php.
185 $sql =
'DESCRIBE ' . $this->
quoteIdentifier(
"$schemaName.$tableName",
true);
195 while (
$row = $queryResult->fetch_assoc()) {
198 $queryResult->close();
203 #require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; 209 $row_defaults = array(
215 'PrimaryPosition' =>
null,
221 $row = array_merge($row_defaults,
$row);
222 if (preg_match(
'/unsigned/',
$row[
'Type'])) {
223 $row[
'Unsigned'] =
true;
225 if (preg_match(
'/^((?:var)?char)\((\d+)\)/',
$row[
'Type'], $matches)) {
226 $row[
'Type'] = $matches[1];
227 $row[
'Length'] = $matches[2];
228 }
else if (preg_match(
'/^decimal\((\d+),(\d+)\)/',
$row[
'Type'], $matches)) {
229 $row[
'Type'] =
'decimal';
230 $row[
'Precision'] = $matches[1];
231 $row[
'Scale'] = $matches[2];
232 }
else if (preg_match(
'/^float\((\d+),(\d+)\)/',
$row[
'Type'], $matches)) {
233 $row[
'Type'] =
'float';
234 $row[
'Precision'] = $matches[1];
235 $row[
'Scale'] = $matches[2];
236 }
else if (preg_match(
'/^((?:big|medium|small|tiny)?int)\((\d+)\)/',
$row[
'Type'], $matches)) {
237 $row[
'Type'] = $matches[1];
243 if (strtoupper(
$row[
'Key']) ==
'PRI') {
244 $row[
'Primary'] =
true;
245 $row[
'PrimaryPosition'] = $p;
246 if (
$row[
'Extra'] ==
'auto_increment') {
247 $row[
'Identity'] =
true;
249 $row[
'Identity'] =
false;
254 'SCHEMA_NAME' =>
null,
257 'COLUMN_POSITION' =>
$i,
258 'DATA_TYPE' =>
$row[
'Type'],
259 'DEFAULT' =>
$row[
'Default'],
260 'NULLABLE' => (
bool) (
$row[
'Null'] ==
'YES'),
261 'LENGTH' =>
$row[
'Length'],
262 'SCALE' =>
$row[
'Scale'],
263 'PRECISION' =>
$row[
'Precision'],
264 'UNSIGNED' =>
$row[
'Unsigned'],
265 'PRIMARY' =>
$row[
'Primary'],
266 'PRIMARY_POSITION' =>
$row[
'PrimaryPosition'],
267 'IDENTITY' =>
$row[
'Identity']
query($sql, $bind=array())
quoteIdentifier($ident, $auto=false)
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.
MySQL does not support sequences, so $tableName and $primaryKey are ignored.
- Parameters
-
string | $tableName | OPTIONAL Name of table. |
string | $primaryKey | OPTIONAL Name of primary key column. |
- Returns
- string
- Todo:
- Return value should be int?
Definition at line 414 of file Mysqli.php.
417 return (
string) $mysqli->insert_id;