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

Public Member Functions

 bindColumn ($column, &$param, $type=null)
 
 bindValue ($parameter, $value, $type=null)
 
 closeCursor ()
 
 columnCount ()
 
 errorCode ()
 
 errorInfo ()
 
 _execute (array $params=null)
 
 fetch ($style=null, $cursor=null, $offset=null)
 
 getIterator ()
 
 fetchAll ($style=null, $col=null)
 
 fetchColumn ($col=0)
 
 fetchObject ($class='stdClass', array $config=array())
 
 getAttribute ($key)
 
 getColumnMeta ($column)
 
 nextRowset ()
 
 rowCount ()
 
 setAttribute ($key, $val)
 
 setFetchMode ($mode)
 
- 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 Member Functions

 _prepare ($sql)
 
 _bindParam ($parameter, &$variable, $type=null, $length=null, $options=null)
 
- Protected Member Functions inherited from Zend_Db_Statement
 _prepare ($sql)
 
 _parseParameters ($sql)
 
 _stripQuoted ($sql)
 

Protected Attributes

 $_fetchMode = PDO::FETCH_ASSOC
 
- 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
 

Detailed Description

Definition at line 40 of file Pdo.php.

Member Function Documentation

◆ _bindParam()

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

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_Exception

Definition at line 100 of file Pdo.php.

101  {
102  try {
103  if ($type === null) {
104  if (is_bool($variable)) {
105  $type = PDO::PARAM_BOOL;
106  } elseif ($variable === null) {
107  $type = PDO::PARAM_NULL;
108  } elseif (is_integer($variable)) {
109  $type = PDO::PARAM_INT;
110  } else {
111  $type = PDO::PARAM_STR;
112  }
113  }
114  return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
115  } catch (PDOException $e) {
116  #require_once 'Zend/Db/Statement/Exception.php';
117  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
118  }
119  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$variable
Definition: variable.php:7
$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_Exception

Definition at line 224 of file Pdo.php.

225  {
226  try {
227  if ($params !== null) {
228  return $this->_stmt->execute($params);
229  } else {
230  return $this->_stmt->execute();
231  }
232  } catch (PDOException $e) {
233  #require_once 'Zend/Db/Statement/Exception.php';
234  $message = sprintf('%s, query was: %s', $e->getMessage(), $this->_stmt->queryString);
235  throw new Zend_Db_Statement_Exception($message, (int) $e->getCode(), $e);
236  }
237  }
$message
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ _prepare()

_prepare (   $sql)
protected

Prepare a string SQL statement and create a statement object.

Parameters
string$sql
Returns
void
Exceptions
Zend_Db_Statement_Exception

Definition at line 55 of file Pdo.php.

56  {
57  try {
58  $this->_stmt = $this->_adapter->getConnection()->prepare($sql);
59  } catch (PDOException $e) {
60  #require_once 'Zend/Db/Statement/Exception.php';
61  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
62  }
63  }

◆ bindColumn()

bindColumn (   $column,
$param,
  $type = null 
)

Bind a column of the statement result set to a PHP variable.

Parameters
string$columnName the column in the result set, either by position or by name.
mixed$paramReference to the PHP variable containing the value.
mixed$typeOPTIONAL
Returns
bool
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 75 of file Pdo.php.

76  {
77  try {
78  if ($type === null) {
79  return $this->_stmt->bindColumn($column, $param);
80  } else {
81  return $this->_stmt->bindColumn($column, $param, $type);
82  }
83  } catch (PDOException $e) {
84  #require_once 'Zend/Db/Statement/Exception.php';
85  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
86  }
87  }
$type
Definition: item.phtml:13

◆ bindValue()

bindValue (   $parameter,
  $value,
  $type = null 
)

Binds a value to a parameter.

Parameters
mixed$parameterName the parameter, either integer or string.
mixed$valueScalar value to bind to the parameter.
mixed$typeOPTIONAL Datatype of the parameter.
Returns
bool
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 130 of file Pdo.php.

131  {
132  if (is_string($parameter) && $parameter[0] != ':') {
133  $parameter = ":$parameter";
134  }
135 
136  $this->_bindParam[$parameter] = $value;
137 
138  try {
139  if ($type === null) {
140  return $this->_stmt->bindValue($parameter, $value);
141  } else {
142  return $this->_stmt->bindValue($parameter, $value, $type);
143  }
144  } catch (PDOException $e) {
145  #require_once 'Zend/Db/Statement/Exception.php';
146  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
147  }
148  }
$type
Definition: item.phtml:13
_bindParam($parameter, &$variable, $type=null, $length=null, $options=null)
Definition: Pdo.php:100
$value
Definition: gender.phtml:16

◆ closeCursor()

closeCursor ( )

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

Returns
bool
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 156 of file Pdo.php.

157  {
158  try {
159  return $this->_stmt->closeCursor();
160  } catch (PDOException $e) {
161  #require_once 'Zend/Db/Statement/Exception.php';
162  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
163  }
164  }

◆ 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.
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 173 of file Pdo.php.

174  {
175  try {
176  return $this->_stmt->columnCount();
177  } catch (PDOException $e) {
178  #require_once 'Zend/Db/Statement/Exception.php';
179  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
180  }
181  }

◆ errorCode()

errorCode ( )

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

Returns
string error code.
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 190 of file Pdo.php.

191  {
192  try {
193  return $this->_stmt->errorCode();
194  } catch (PDOException $e) {
195  #require_once 'Zend/Db/Statement/Exception.php';
196  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
197  }
198  }

◆ errorInfo()

errorInfo ( )

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

Returns
array
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 207 of file Pdo.php.

208  {
209  try {
210  return $this->_stmt->errorInfo();
211  } catch (PDOException $e) {
212  #require_once 'Zend/Db/Statement/Exception.php';
213  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
214  }
215  }

◆ 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_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 248 of file Pdo.php.

249  {
250  if ($style === null) {
251  $style = $this->_fetchMode;
252  }
253  try {
254  return $this->_stmt->fetch($style, $cursor, $offset);
255  } catch (PDOException $e) {
256  #require_once 'Zend/Db/Statement/Exception.php';
257  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
258  }
259  }

◆ 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.
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 279 of file Pdo.php.

280  {
281  if ($style === null) {
282  $style = $this->_fetchMode;
283  }
284  try {
285  if ($style == PDO::FETCH_COLUMN) {
286  if ($col === null) {
287  $col = 0;
288  }
289  return $this->_stmt->fetchAll($style, $col);
290  } else {
291  return $this->_stmt->fetchAll($style);
292  }
293  } catch (PDOException $e) {
294  #require_once 'Zend/Db/Statement/Exception.php';
295  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
296  }
297  }

◆ fetchColumn()

fetchColumn (   $col = 0)

Returns a single column from the next row of a result set.

Parameters
int$colOPTIONAL Position of the column to fetch.
Returns
string
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 306 of file Pdo.php.

307  {
308  try {
309  return $this->_stmt->fetchColumn($col);
310  } catch (PDOException $e) {
311  #require_once 'Zend/Db/Statement/Exception.php';
312  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
313  }
314  }

◆ 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.
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 324 of file Pdo.php.

325  {
326  try {
327  return $this->_stmt->fetchObject($class, $config);
328  } catch (PDOException $e) {
329  #require_once 'Zend/Db/Statement/Exception.php';
330  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
331  }
332  }
$config
Definition: fraud_order.php:17
$_option $_optionId $class
Definition: date.phtml:13

◆ getAttribute()

getAttribute (   $key)

Retrieve a statement attribute.

Parameters
integer$keyAttribute name.
Returns
mixed Attribute value.
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 341 of file Pdo.php.

342  {
343  try {
344  return $this->_stmt->getAttribute($key);
345  } catch (PDOException $e) {
346  #require_once 'Zend/Db/Statement/Exception.php';
347  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
348  }
349  }

◆ getColumnMeta()

getColumnMeta (   $column)

Returns metadata for a column in a result set.

Parameters
int$column
Returns
mixed
Exceptions
Zend_Db_Statement_Exception

Definition at line 358 of file Pdo.php.

359  {
360  try {
361  return $this->_stmt->getColumnMeta($column);
362  } catch (PDOException $e) {
363  #require_once 'Zend/Db/Statement/Exception.php';
364  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
365  }
366  }

◆ getIterator()

getIterator ( )

Required by IteratorAggregate interface

Returns
IteratorIterator

Definition at line 266 of file Pdo.php.

267  {
268  return new IteratorIterator($this->_stmt);
269  }

◆ 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_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 376 of file Pdo.php.

377  {
378  try {
379  return $this->_stmt->nextRowset();
380  } catch (PDOException $e) {
381  #require_once 'Zend/Db/Statement/Exception.php';
382  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
383  }
384  }

◆ 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.
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 394 of file Pdo.php.

395  {
396  try {
397  return $this->_stmt->rowCount();
398  } catch (PDOException $e) {
399  #require_once 'Zend/Db/Statement/Exception.php';
400  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
401  }
402  }

◆ setAttribute()

setAttribute (   $key,
  $val 
)

Set a statement attribute.

Parameters
string$keyAttribute name.
mixed$valAttribute value.
Returns
bool
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 412 of file Pdo.php.

413  {
414  try {
415  return $this->_stmt->setAttribute($key, $val);
416  } catch (PDOException $e) {
417  #require_once 'Zend/Db/Statement/Exception.php';
418  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
419  }
420  }

◆ setFetchMode()

setFetchMode (   $mode)

Set the default fetch mode for this statement.

Parameters
int$modeThe fetch mode.
Returns
bool
Exceptions
Zend_Db_Statement_Exception

Implements Zend_Db_Statement_Interface.

Definition at line 429 of file Pdo.php.

430  {
431  $this->_fetchMode = $mode;
432  try {
433  return $this->_stmt->setFetchMode($mode);
434  } catch (PDOException $e) {
435  #require_once 'Zend/Db/Statement/Exception.php';
436  throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
437  }
438  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15

Field Documentation

◆ $_fetchMode

$_fetchMode = PDO::FETCH_ASSOC
protected

Definition at line 46 of file Pdo.php.


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