Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Mysql.php
Go to the documentation of this file.
1 <?php
13 
15 
17 {
27  public function _executeWithBinding(array $params)
28  {
29  // Check whether we deal with named bind
30  $isPositionalBind = true;
31  foreach ($params as $k => $v) {
32  if (!is_int($k)) {
33  $isPositionalBind = false;
34  break;
35  }
36  }
37 
38  /* @var $statement \PDOStatement */
39  $statement = $this->_stmt;
40  $bindValues = [];
41  // Separate array with values, as they are bound by reference
42  foreach ($params as $name => $param) {
43  $dataType = \PDO::PARAM_STR;
44  $length = null;
45  $driverOptions = null;
46 
47  if ($param instanceof Parameter) {
48  if ($param->getIsBlob()) {
49  // Nothing to do there - default options are fine for MySQL driver
50  } else {
51  $dataType = $param->getDataType();
52  $length = $param->getLength();
53  $driverOptions = $param->getDriverOptions();
54  }
55  $bindValues[$name] = $param->getValue();
56  } else {
57  $bindValues[$name] = $param;
58  }
59 
60  $paramName = $isPositionalBind ? $name + 1 : $name;
61  $statement->bindParam($paramName, $bindValues[$name], $dataType, $length, $driverOptions);
62  }
63 
64  try {
65  return $statement->execute();
66  } catch (\PDOException $e) {
67  throw new \Zend_Db_Statement_Exception($e->getMessage(), (int)$e->getCode(), $e);
68  }
69  }
70 
78  public function _execute(array $params = null)
79  {
80  $specialExecute = false;
81  if ($params) {
82  foreach ($params as $param) {
83  if ($param instanceof Parameter) {
84  $specialExecute = true;
85  break;
86  }
87  }
88  }
89 
90  if ($specialExecute) {
91  return $this->_executeWithBinding($params);
92  } else {
93  return parent::_execute($params);
94  }
95  }
96 }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
if(!isset($_GET['name'])) $name
Definition: log.php:14