Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Zend_Db_Adapter_Pdo_Ibm Class Reference
Inheritance diagram for Zend_Db_Adapter_Pdo_Ibm:
Zend_Db_Adapter_Pdo_Abstract Zend_Db_Adapter_Abstract

Public Member Functions

 _connect ()
 
 prepare ($sql)
 
 listTables ()
 
 describeTable ($tableName, $schemaName=null)
 
 insert ($table, array $bind)
 
 limit ($sql, $count, $offset=0)
 
 lastInsertId ($tableName=null, $primaryKey=null)
 
 lastSequenceId ($sequenceName)
 
 nextSequenceId ($sequenceName)
 
 getServerVersion ()
 
- Public Member Functions inherited from Zend_Db_Adapter_Pdo_Abstract
 isConnected ()
 
 closeConnection ()
 
 prepare ($sql)
 
 lastInsertId ($tableName=null, $primaryKey=null)
 
 query ($sql, $bind=array())
 
 exec ($sql)
 
 setFetchMode ($mode)
 
 supportsParameters ($type)
 
 getServerVersion ()
 
- Public Member Functions inherited from Zend_Db_Adapter_Abstract
 __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 ()
 

Protected Member Functions

 _dsn ()
 
 _checkRequiredOptions (array $config)
 
- Protected Member Functions inherited from Zend_Db_Adapter_Pdo_Abstract
 _dsn ()
 
 _connect ()
 
 _quote ($value)
 
 _beginTransaction ()
 
 _commit ()
 
 _rollBack ()
 
- Protected Member Functions inherited from Zend_Db_Adapter_Abstract
 _checkRequiredOptions (array $config)
 
 _whereExpr ($where)
 
 _quote ($value)
 
 _quoteIdentifierAs ($ident, $alias=null, $auto=false, $as=' AS ')
 
 _quoteIdentifier ($value, $auto=false)
 
 _connect ()
 
 _beginTransaction ()
 
 _commit ()
 
 _rollBack ()
 

Protected Attributes

 $_pdoType = 'ibm'
 
 $_serverType = null
 
 $_numericDataTypes
 
- Protected Attributes inherited from Zend_Db_Adapter_Pdo_Abstract
 $_defaultStmtClass = 'Zend_Db_Statement_Pdo'
 
- Protected Attributes inherited from Zend_Db_Adapter_Abstract
 $_config = array()
 
 $_fetchMode = Zend_Db::FETCH_ASSOC
 
 $_profiler
 
 $_defaultStmtClass = 'Zend_Db_Statement'
 
 $_defaultProfilerClass = 'Zend_Db_Profiler'
 
 $_connection = null
 
 $_caseFolding = Zend_Db::CASE_NATURAL
 
 $_autoQuoteIdentifiers = true
 
 $_numericDataTypes
 
 $_allowSerialization = true
 
 $_autoReconnectOnUnserialize = false
 

Detailed Description

Definition at line 44 of file Ibm.php.

Member Function Documentation

◆ _checkRequiredOptions()

_checkRequiredOptions ( array  $config)
protected

Checks required options

Parameters
array$config
Exceptions
Zend_Db_Adapter_Exception
Returns
void
See also
Zend_Db_Adapter_Exception

Definition at line 174 of file Ibm.php.

175  {
176  parent::_checkRequiredOptions($config);
177 
178  if (array_key_exists('host', $this->_config) &&
179  !array_key_exists('port', $config)) {
181  #require_once 'Zend/Db/Adapter/Exception.php';
182  throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified");
183  }
184  }
$config
Definition: fraud_order.php:17

◆ _connect()

_connect ( )

Creates a PDO object and connects to the database.

The IBM data server is set. Current options are DB2 or IDS

Todo:
also differentiate between z/OS and i/5
Returns
void
Exceptions
Zend_Db_Adapter_Exception
See also
Zend_Db_Adapter_Exception

Definition at line 96 of file Ibm.php.

97  {
98  if ($this->_connection) {
99  return;
100  }
101  parent::_connect();
102 
103  $this->getConnection()->setAttribute(Zend_Db::ATTR_STRINGIFY_FETCHES, true);
104 
105  try {
106  if ($this->_serverType === null) {
107  $server = substr($this->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3);
108 
109  switch ($server) {
110  case 'DB2':
111  $this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Db2($this);
112 
113  // Add DB2-specific numeric types
114  $this->_numericDataTypes['DECFLOAT'] = Zend_Db::FLOAT_TYPE;
115  $this->_numericDataTypes['DOUBLE'] = Zend_Db::FLOAT_TYPE;
116  $this->_numericDataTypes['NUM'] = Zend_Db::FLOAT_TYPE;
117 
118  break;
119  case 'IDS':
120  $this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Ids($this);
121 
122  // Add IDS-specific numeric types
123  $this->_numericDataTypes['SERIAL'] = Zend_Db::INT_TYPE;
124  $this->_numericDataTypes['SERIAL8'] = Zend_Db::BIGINT_TYPE;
125  $this->_numericDataTypes['INT8'] = Zend_Db::BIGINT_TYPE;
126  $this->_numericDataTypes['SMALLFLOAT'] = Zend_Db::FLOAT_TYPE;
127  $this->_numericDataTypes['MONEY'] = Zend_Db::FLOAT_TYPE;
128 
129  break;
130  }
131  }
132  } catch (PDOException $e) {
134  #require_once 'Zend/Db/Adapter/Exception.php';
135  $error = strpos($e->getMessage(), 'driver does not support that attribute');
136  if ($error) {
137  throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e);
138  } else {
139  throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
140  }
141  }
142  }
const ATTR_STRINGIFY_FETCHES
Definition: Db.php:121
const BIGINT_TYPE
Definition: Db.php:69
const INT_TYPE
Definition: Db.php:68
const FLOAT_TYPE
Definition: Db.php:70

◆ _dsn()

_dsn ( )
protected

Creates a PDO DSN for the adapter from $this->_config settings.

Returns
string

Definition at line 149 of file Ibm.php.

150  {
151  $this->_checkRequiredOptions($this->_config);
152 
153  // check if using full connection string
154  if (array_key_exists('host', $this->_config)) {
155  $dsn = ';DATABASE=' . $this->_config['dbname']
156  . ';HOSTNAME=' . $this->_config['host']
157  . ';PORT=' . $this->_config['port']
158  // PDO_IBM supports only DB2 TCPIP protocol
159  . ';PROTOCOL=' . 'TCPIP;';
160  } else {
161  // catalogued connection
162  $dsn = $this->_config['dbname'];
163  }
164  return $this->_pdoType . ': ' . $dsn;
165  }
_checkRequiredOptions(array $config)
Definition: Ibm.php:174

◆ describeTable()

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

Todo:
Discover integer unsigned property.
Parameters
string$tableName
string$schemaNameOPTIONAL
Returns
array

Definition at line 242 of file Ibm.php.

243  {
244  $this->_connect();
245  return $this->_serverType->describeTable($tableName, $schemaName);
246  }
$tableName
Definition: trigger.php:13

◆ getServerVersion()

getServerVersion ( )

Retrieve server version in PHP style Pdo_Idm doesn't support getAttribute(PDO::ATTR_SERVER_VERSION)

Returns
string

Definition at line 342 of file Ibm.php.

343  {
344  try {
345  $stmt = $this->query('SELECT service_level, fixpack_num FROM TABLE (sysproc.env_get_inst_info()) as INSTANCEINFO');
346  $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
347  if (count($result)) {
348  $matches = null;
349  if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $result[0][0], $matches)) {
350  return $matches[1];
351  } else {
352  return null;
353  }
354  }
355  return null;
356  } catch (PDOException $e) {
357  return null;
358  }
359  }
const FETCH_NUM
Definition: Db.php:153
query($sql, $bind=array())
Definition: Abstract.php:221

◆ insert()

insert (   $table,
array  $bind 
)

Inserts a table row with specified data. Special handling for PDO_IBM remove empty slots

Parameters
mixed$tableThe table to insert data into.
array$bindColumn-value pairs.
Returns
int The number of affected rows.

Definition at line 257 of file Ibm.php.

258  {
259  $this->_connect();
260  $newbind = array();
261  if (is_array($bind)) {
262  foreach ($bind as $name => $value) {
263  if($value !== null) {
264  $newbind[$name] = $value;
265  }
266  }
267  }
268 
269  return parent::insert($table, $newbind);
270  }
$value
Definition: gender.phtml:16
$table
Definition: trigger.php:14
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ lastInsertId()

lastInsertId (   $tableName = null,
  $primaryKey = null 
)

Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.

Parameters
string$tableNameOPTIONAL
string$primaryKeyOPTIONAL
Returns
integer

Definition at line 294 of file Ibm.php.

295  {
296  $this->_connect();
297 
298  if ($tableName !== null) {
299  $sequenceName = $tableName;
300  if ($primaryKey) {
301  $sequenceName .= "_$primaryKey";
302  }
303  $sequenceName .= '_seq';
304  return $this->lastSequenceId($sequenceName);
305  }
306 
307  $id = $this->getConnection()->lastInsertId();
308 
309  return $id;
310  }
$tableName
Definition: trigger.php:13
$id
Definition: fieldset.phtml:14
lastSequenceId($sequenceName)
Definition: Ibm.php:318

◆ lastSequenceId()

lastSequenceId (   $sequenceName)

Return the most recent value from the specified sequence in the database.

Parameters
string$sequenceName
Returns
integer

Definition at line 318 of file Ibm.php.

319  {
320  $this->_connect();
321  return $this->_serverType->lastSequenceId($sequenceName);
322  }

◆ limit()

limit (   $sql,
  $count,
  $offset = 0 
)

Adds an adapter-specific LIMIT clause to the SELECT statement.

Parameters
string$sql
integer$count
integer$offsetOPTIONAL
Returns
string

Definition at line 280 of file Ibm.php.

281  {
282  $this->_connect();
283  return $this->_serverType->limit($sql, $count, $offset);
284  }
$count
Definition: recent.phtml:13

◆ listTables()

listTables ( )

Returns a list of the tables in the database.

Returns
array

Definition at line 207 of file Ibm.php.

208  {
209  $this->_connect();
210  return $this->_serverType->listTables();
211  }

◆ nextSequenceId()

nextSequenceId (   $sequenceName)

Generate a new value from the specified sequence in the database, and return it.

Parameters
string$sequenceName
Returns
integer

Definition at line 331 of file Ibm.php.

332  {
333  $this->_connect();
334  return $this->_serverType->nextSequenceId($sequenceName);
335  }

◆ prepare()

prepare (   $sql)

Prepares an SQL statement.

Parameters
string$sqlThe SQL statement with placeholders.
array$bindAn array of data to bind to the placeholders.
Returns
PDOStatement

Definition at line 193 of file Ibm.php.

194  {
195  $this->_connect();
196  $stmtClass = $this->_defaultStmtClass;
197  $stmt = new $stmtClass($this, $sql);
198  $stmt->setFetchMode($this->_fetchMode);
199  return $stmt;
200  }

Field Documentation

◆ $_numericDataTypes

$_numericDataTypes
protected
Initial value:

Definition at line 71 of file Ibm.php.

◆ $_pdoType

$_pdoType = 'ibm'
protected

Definition at line 51 of file Ibm.php.

◆ $_serverType

$_serverType = null
protected

Definition at line 58 of file Ibm.php.


The documentation for this class was generated from the following file: