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

Public Member Functions

 _prepare ($sql)
 
 _bindParam ($parameter, &$variable, $type=null, $length=null, $options=null)
 
 closeCursor ()
 
 columnCount ()
 
 errorCode ()
 
 errorInfo ()
 
 _execute (array $params=null)
 
 fetch ($style=null, $cursor=null, $offset=null)
 
 fetchObject ($class='stdClass', array $config=array())
 
 nextRowset ()
 
 rowCount ()
 
 fetchAll ($style=null, $col=null)
 
- Public Member Functions inherited from Zend_Db_Statement
 __construct ($adapter, $sql)
 
 bindColumn ($column, &$param, $type=null)
 
 bindParam ($parameter, &$variable, $type=null, $length=null, $options=null)
 
 bindValue ($parameter, $value, $type=null)
 
 execute (array $params=null)
 
 fetchAll ($style=null, $col=null)
 
 fetchColumn ($col=0)
 
 fetchObject ($class='stdClass', array $config=array())
 
 getAttribute ($key)
 
 setAttribute ($key, $val)
 
 setFetchMode ($mode)
 
 _fetchBound ($row)
 
 getAdapter ()
 
 getDriverStatement ()
 

Protected Attributes

 $_keys
 
 $_values
 
- Protected Attributes inherited from Zend_Db_Statement
 $_stmt = null
 
 $_adapter = null
 
 $_fetchMode = Zend_Db::FETCH_ASSOC
 
 $_attribute = array()
 
 $_bindColumn = array()
 
 $_bindParam = array()
 
 $_sqlSplit = array()
 
 $_sqlParam = array()
 
 $_queryId = null
 

Additional Inherited Members

- Protected Member Functions inherited from Zend_Db_Statement
 _prepare ($sql)
 
 _parseParameters ($sql)
 
 _stripQuoted ($sql)
 

Detailed Description

Definition at line 36 of file Db2.php.

Member Function Documentation

◆ _bindParam()

_bindParam (   $parameter,
$variable,
  $type = null,
  $length = null,
  $options = null 
)

Binds a parameter to the specified variable name.

Parameters
mixed$parameterName the parameter, either integer or string.
mixed$variableReference to PHP variable containing the value.
mixed$typeOPTIONAL Datatype of SQL parameter.
mixed$lengthOPTIONAL Length of SQL parameter.
mixed$optionsOPTIONAL Other options.
Returns
bool
Exceptions
Zend_Db_Statement_Db2_Exception
See also
Zend_Db_Statement_Db2_Exception

Definition at line 87 of file Db2.php.

88  {
89  if ($type === null) {
90  $type = DB2_PARAM_IN;
91  }
92 
93  if (isset($options['data-type'])) {
94  $datatype = $options['data-type'];
95  } else {
96  $datatype = DB2_CHAR;
97  }
98 
99  if (!db2_bind_param($this->_stmt, $parameter, "variable", $type, $datatype)) {
103  #require_once 'Zend/Db/Statement/Db2/Exception.php';
105  db2_stmt_errormsg(),
106  db2_stmt_error()
107  );
108  }
109 
110  return true;
111  }
$type
Definition: item.phtml:13

◆ _execute()

_execute ( array  $params = null)

Executes a prepared statement.

Parameters
array$paramsOPTIONAL Values to bind to parameter placeholders.
Returns
bool
Exceptions
Zend_Db_Statement_Db2_Exception
See also
Zend_Db_Statement_Db2_Exception

Definition at line 194 of file Db2.php.

195  {
196  if (!$this->_stmt) {
197  return false;
198  }
199 
200  $retval = true;
201  if ($params !== null) {
202  $retval = @db2_execute($this->_stmt, $params);
203  } else {
204  $retval = @db2_execute($this->_stmt);
205  }
206 
207  if ($retval === false) {
211  #require_once 'Zend/Db/Statement/Db2/Exception.php';
213  db2_stmt_errormsg(),
214  db2_stmt_error());
215  }
216 
217  $this->_keys = array();
218  if ($field_num = $this->columnCount()) {
219  for ($i = 0; $i < $field_num; $i++) {
220  $name = db2_field_name($this->_stmt, $i);
221  $this->_keys[] = $name;
222  }
223  }
224 
225  $this->_values = array();
226  if ($this->_keys) {
227  $this->_values = array_fill(0, count($this->_keys), null);
228  }
229 
230  return $retval;
231  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
$i
Definition: gallery.phtml:31
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ _prepare()

_prepare (   $sql)

Prepare a statement handle.

Parameters
string$sql
Returns
void
Exceptions
Zend_Db_Statement_Db2_Exception
See also
Zend_Db_Statement_Db2_Exception

Definition at line 56 of file Db2.php.

57  {
58  $connection = $this->_adapter->getConnection();
59 
60  // db2_prepare on i5 emits errors, these need to be
61  // suppressed so that proper exceptions can be thrown
62  $this->_stmt = @db2_prepare($connection, $sql);
63 
64  if (!$this->_stmt) {
68  #require_once 'Zend/Db/Statement/Db2/Exception.php';
70  db2_stmt_errormsg(),
71  db2_stmt_error()
72  );
73  }
74  }
$connection
Definition: bulk.php:13

◆ closeCursor()

closeCursor ( )

Closes the cursor, allowing the statement to be executed again.

Returns
bool

Implements Zend_Db_Statement_Interface.

Definition at line 118 of file Db2.php.

119  {
120  if (!$this->_stmt) {
121  return false;
122  }
123  db2_free_stmt($this->_stmt);
124  $this->_stmt = false;
125  return true;
126  }

◆ columnCount()

columnCount ( )

Returns the number of columns in the result set. Returns null if the statement has no result set metadata.

Returns
int The number of columns.

Implements Zend_Db_Statement_Interface.

Definition at line 135 of file Db2.php.

136  {
137  if (!$this->_stmt) {
138  return false;
139  }
140  return db2_num_fields($this->_stmt);
141  }

◆ errorCode()

errorCode ( )

Retrieves the error code, if any, associated with the last operation on the statement handle.

Returns
string error code.

Implements Zend_Db_Statement_Interface.

Definition at line 149 of file Db2.php.

150  {
151  if (!$this->_stmt) {
152  return false;
153  }
154 
155  $error = db2_stmt_error();
156  if ($error === '') {
157  return false;
158  }
159 
160  return $error;
161  }

◆ errorInfo()

errorInfo ( )

Retrieves an array of error information, if any, associated with the last operation on the statement handle.

Returns
array

Implements Zend_Db_Statement_Interface.

Definition at line 169 of file Db2.php.

170  {
171  $error = $this->errorCode();
172  if ($error === false){
173  return false;
174  }
175 
176  /*
177  * Return three-valued array like PDO. But DB2 does not distinguish
178  * between SQLCODE and native RDBMS error code, so repeat the SQLCODE.
179  */
180  return array(
181  $error,
182  $error,
183  db2_stmt_errormsg()
184  );
185  }

◆ fetch()

fetch (   $style = null,
  $cursor = null,
  $offset = null 
)

Fetches a row from the result set.

Parameters
int$styleOPTIONAL Fetch mode for this fetch operation.
int$cursorOPTIONAL Absolute, relative, or other.
int$offsetOPTIONAL Number for absolute or relative cursors.
Returns
mixed Array, object, or scalar depending on fetch mode.
Exceptions
Zend_Db_Statement_Db2_Exception
See also
Zend_Db_Statement_Db2_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 242 of file Db2.php.

243  {
244  if (!$this->_stmt) {
245  return false;
246  }
247 
248  if ($style === null) {
249  $style = $this->_fetchMode;
250  }
251 
252  switch ($style) {
253  case Zend_Db::FETCH_NUM :
254  $row = db2_fetch_array($this->_stmt);
255  break;
256  case Zend_Db::FETCH_ASSOC :
257  $row = db2_fetch_assoc($this->_stmt);
258  break;
259  case Zend_Db::FETCH_BOTH :
260  $row = db2_fetch_both($this->_stmt);
261  break;
262  case Zend_Db::FETCH_OBJ :
263  $row = db2_fetch_object($this->_stmt);
264  break;
266  $row = db2_fetch_both($this->_stmt);
267  if ($row !== false) {
268  return $this->_fetchBound($row);
269  }
270  break;
271  default:
275  #require_once 'Zend/Db/Statement/Db2/Exception.php';
276  throw new Zend_Db_Statement_Db2_Exception("Invalid fetch mode '$style' specified");
277  break;
278  }
279 
280  return $row;
281  }
const FETCH_BOUND
Definition: Db.php:144
const FETCH_ASSOC
Definition: Db.php:142
const FETCH_BOTH
Definition: Db.php:143
const FETCH_NUM
Definition: Db.php:153
const FETCH_OBJ
Definition: Db.php:154

◆ fetchAll()

fetchAll (   $style = null,
  $col = null 
)

Returns an array containing all of the result set rows.

Parameters
int$styleOPTIONAL Fetch mode.
int$colOPTIONAL Column number, if fetch mode is by column.
Returns
array Collection of rows, each in a format by the fetch mode.

Behaves like parent, but if limit() is used, the final result removes the extra column 'zend_db_rownum'

Implements Zend_Db_Statement_Interface.

Definition at line 346 of file Db2.php.

347  {
348  $data = parent::fetchAll($style, $col);
349  $results = array();
350  $remove = $this->_adapter->foldCase('ZEND_DB_ROWNUM');
351 
352  foreach ($data as $row) {
353  if (is_array($row) && array_key_exists($remove, $row)) {
354  unset($row[$remove]);
355  }
356  $results[] = $row;
357  }
358  return $results;
359  }
$results
Definition: popup.phtml:13

◆ fetchObject()

fetchObject (   $class = 'stdClass',
array  $config = array() 
)

Fetches the next row and returns it as an object.

Parameters
string$classOPTIONAL Name of the class to create.
array$configOPTIONAL Constructor arguments for the class.
Returns
mixed One object instance of the specified class.

Implements Zend_Db_Statement_Interface.

Definition at line 290 of file Db2.php.

291  {
292  $obj = $this->fetch(Zend_Db::FETCH_OBJ);
293  return $obj;
294  }
const FETCH_OBJ
Definition: Db.php:154
fetch($style=null, $cursor=null, $offset=null)
Definition: Db2.php:242

◆ nextRowset()

nextRowset ( )

Retrieves the next rowset (result set) for a SQL statement that has multiple result sets. An example is a stored procedure that returns the results of multiple queries.

Returns
bool
Exceptions
Zend_Db_Statement_Db2_Exception
See also
Zend_Db_Statement_Db2_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 304 of file Db2.php.

305  {
309  #require_once 'Zend/Db/Statement/Db2/Exception.php';
310  throw new Zend_Db_Statement_Db2_Exception(__FUNCTION__ . '() is not implemented');
311  }

◆ rowCount()

rowCount ( )

Returns the number of rows affected by the execution of the last INSERT, DELETE, or UPDATE statement executed by this statement object.

Returns
int The number of rows affected.

Implements Zend_Db_Statement_Interface.

Definition at line 320 of file Db2.php.

321  {
322  if (!$this->_stmt) {
323  return false;
324  }
325 
326  $num = @db2_num_rows($this->_stmt);
327 
328  if ($num === false) {
329  return 0;
330  }
331 
332  return $num;
333  }

Field Documentation

◆ $_keys

$_keys
protected

Column names.

Definition at line 42 of file Db2.php.

◆ $_values

$_values
protected

Fetched result values.

Definition at line 47 of file Db2.php.


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