Definition at line 38 of file Db2.php.
◆ __construct()
Construct the data server class.
It will be used to generate non-generic SQL for a particular data server
- Parameters
-
Definition at line 53 of file Db2.php.
◆ describeTable()
describeTable |
( |
|
$tableName, |
|
|
|
$schemaName = null |
|
) |
| |
DB2 catalog lookup for describe table
- Parameters
-
string | $tableName | |
string | $schemaName | OPTIONAL |
- Returns
- array
To avoid case issues, fetch using FETCH_NUM
The ordering of columns is defined by the query so we can map to variables to improve readability
In IBM DB2, an column can be IDENTITY even if it is not part of the PRIMARY KEY.
Definition at line 77 of file Db2.php.
79 $sql =
"SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno, 80 c.typename, c.default, c.nulls, c.length, c.scale, 81 c.identity, tc.type AS tabconsttype, k.colseq 83 LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc 84 ON (k.tabschema = tc.tabschema 85 AND k.tabname = tc.tabname 87 ON (c.tabschema = k.tabschema 88 AND c.tabname = k.tabname 89 AND c.colname = k.colname) 91 . $this->_adapter->quoteInto(
'UPPER(c.tabname) = UPPER(?)',
$tableName);
93 $sql .= $this->_adapter->quoteInto(
' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
95 $sql .=
" ORDER BY c.colno";
98 $stmt = $this->_adapter->query($sql);
123 list ($primary, $primaryPosition, $identity) = array(
false,
null,
false);
124 if (
$row[$tabconstype] ==
'P') {
126 $primaryPosition =
$row[$colseq];
132 if (
$row[$identityCol] ==
'Y') {
136 $desc[$this->_adapter->foldCase(
$row[$colname])] = array(
137 'SCHEMA_NAME' => $this->_adapter->foldCase(
$row[$tabschema]),
138 'TABLE_NAME' => $this->_adapter->foldCase(
$row[$tabname]),
139 'COLUMN_NAME' => $this->_adapter->foldCase(
$row[$colname]),
140 'COLUMN_POSITION' =>
$row[$colno]+1,
141 'DATA_TYPE' =>
$row[$typename],
142 'DEFAULT' =>
$row[$default],
143 'NULLABLE' => (bool) (
$row[$nulls] ==
'Y'),
144 'LENGTH' =>
$row[$length],
145 'SCALE' =>
$row[$scale],
146 'PRECISION' => (
$row[$typename] ==
'DECIMAL' ?
$row[$length] : 0),
148 'PRIMARY' => $primary,
149 'PRIMARY_POSITION' => $primaryPosition,
150 'IDENTITY' => $identity
◆ lastSequenceId()
lastSequenceId |
( |
|
$sequenceName | ) |
|
DB2-specific last sequence id
- Parameters
-
- Returns
- integer
Definition at line 209 of file Db2.php.
211 $sql =
'SELECT PREVVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).
' AS VAL FROM SYSIBM.SYSDUMMY1';
212 $value = $this->_adapter->fetchOne($sql);
◆ limit()
limit |
( |
|
$sql, |
|
|
|
$count, |
|
|
|
$offset = 0 |
|
) |
| |
Adds a DB2-specific LIMIT clause to the SELECT statement.
- Parameters
-
string | $sql | |
integer | $count | |
integer | $offset | OPTIONAL |
- Exceptions
-
- Returns
- string
- See also
- Zend_Db_Adapter_Exception
-
Zend_Db_Adapter_Exception
DB2 does not implement the LIMIT clause as some RDBMS do. We have to simulate it with subqueries and ROWNUM. Unfortunately because we use the column wildcard "*", this puts an extra column into the query result set.
Definition at line 166 of file Db2.php.
171 #require_once 'Zend/Db/Adapter/Exception.php'; 174 $offset = intval($offset);
177 #require_once 'Zend/Db/Adapter/Exception.php'; 181 if ($offset == 0 &&
$count > 0) {
182 $limit_sql = $sql .
" FETCH FIRST $count ROWS ONLY";
191 $limit_sql =
"SELECT z2.* 193 SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.* 198 WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) .
" AND " . ($offset+
$count);
◆ listTables()
Returns a list of the tables in the database.
- Returns
- array
Definition at line 63 of file Db2.php.
65 $sql =
"SELECT tabname " 66 .
"FROM SYSCAT.TABLES ";
67 return $this->_adapter->fetchCol($sql);
◆ nextSequenceId()
nextSequenceId |
( |
|
$sequenceName | ) |
|
DB2-specific sequence id value
- Parameters
-
- Returns
- integer
Definition at line 222 of file Db2.php.
224 $sql =
'SELECT NEXTVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).
' AS VAL FROM SYSIBM.SYSDUMMY1';
225 $value = $this->_adapter->fetchOne($sql);
◆ $_adapter
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php