当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli_stmt::execute方法代码示例

本文整理汇总了PHP中mysqli_stmt::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt::execute方法的具体用法?PHP mysqli_stmt::execute怎么用?PHP mysqli_stmt::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysqli_stmt的用法示例。


在下文中一共展示了mysqli_stmt::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * 执行sql
  *
  * @return bool|int
  */
 public function execute()
 {
     if (!$this->prepare) {
         return false;
     }
     $res = $this->prepare->execute();
     $this->mysql->error = $this->prepare->error;
     $this->mysql->errno = $this->prepare->errno;
     if ($res) {
         $id = $this->prepare->insert_id;
         $affected_rows = $this->prepare->affected_rows;
         if ($id) {
             $this->mysql->insert_id = $id;
             return $id;
         }
         //有时候执行更新操作并没有改变任何数据也认为成功
         if ($affected_rows >= 0) {
             $this->mysql->affected_rows = $affected_rows;
             return true;
         }
         return false;
     } else {
         return false;
     }
 }
开发者ID:qazzhoubin,项目名称:emptyphp,代码行数:30,代码来源:MysqlStmt.php

示例2: execute

 /**
  * Executes a query that has been previously prepared using the mysqli_prepare() function.
  * When executed any parameter markers which exist will automatically be replaced with the appropriate data.
  */
 public function execute()
 {
     $this->stmt->execute();
     if ($this->stmt->error) {
         $this->errors = true;
     }
 }
开发者ID:Sala,项目名称:skype-stats,代码行数:11,代码来源:DB.php

示例3: execute

 public function execute()
 {
     if (count($this->mbind_params)) {
         $this->mbind_param_do();
     }
     return parent::execute();
 }
开发者ID:jonca44,项目名称:pdf-mailmerge,代码行数:7,代码来源:iSQL.php

示例4: execute

 /**
  * Execute
  *
  * @param  ParameterContainer $parameters
  * @return mixed
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     /** START Standard ParameterContainer Merging Block */
     if (!$this->parameterContainer instanceof ParameterContainer) {
         if ($parameters instanceof ParameterContainer) {
             $this->parameterContainer = $parameters;
             $parameters = null;
         } else {
             $this->parameterContainer = new ParameterContainer();
         }
     }
     if (is_array($parameters)) {
         $this->parameterContainer->setFromArray($parameters);
     }
     if ($this->parameterContainer->count() > 0) {
         $this->bindParametersFromContainer();
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->resource->execute() === false) {
         throw new Exception\RuntimeException($this->resource->error);
     }
     if ($this->bufferResults === true) {
         $this->resource->store_result();
         $this->isPrepared = false;
         $buffered = true;
     } else {
         $buffered = false;
     }
     $result = $this->driver->createResult($this->resource, $buffered);
     return $result;
 }
开发者ID:Rovak,项目名称:zf2,代码行数:40,代码来源:Statement.php

示例5: executar

 /**
  * executar
  * Recebe os dados, monta o bind_param e executa.
  * 
  * @param array
  * @throws Exception
  */
 protected function executar(array $dados)
 {
     /** @var array */
     $params = $this->prepararDados($dados);
     /** Passa os paramentros ao bind_param */
     if (count($dados) > 0) {
         if ($this->stmt) {
             call_user_func_array(array($this->stmt, 'bind_param'), $this->makeValuesReferenced($params));
         } else {
             throw new Exception("Erro ao executar \"{$this->mysqli->error}\"", $this->mysqli->errno);
         }
     }
     /** Executa a consulta e verifica se ocorreu algum erro */
     if (!$this->stmt->execute()) {
         throw new Exception("Erro ao executar: (" . $this->stmt->error . ") ", $this->stmt->errno);
     }
     /** Preenche o array de dados caso haja algum retorno */
     $this->result = array();
     $r = $this->stmt->get_result();
     if ($r) {
         while ($row = $r->fetch_assoc()) {
             $this->result[] = $row;
         }
     }
     /** Fecha o stamtment e a conexao com o banco */
     $this->stmt->close();
     $this->mysqli->close();
 }
开发者ID:Giselly,项目名称:AVAWEB_Responsivo,代码行数:35,代码来源:ConexaoDAO.class.php

示例6: _execute

 /**
  * Executes the query
  */
 private function _execute()
 {
     $this->_query->execute();
     $this->last_error = $this->_query->error;
     $this->last_errno = $this->_query->errno;
     $this->num_rows = $this->_query->num_rows;
     $this->affected_rows = $this->_query->affected_rows;
     $this->insert_id = $this->_query->insert_id;
 }
开发者ID:NightWingStudios,项目名称:Nightshade,代码行数:12,代码来源:Query.php

示例7: executePreparedStatement

 /**
  * (non-PHPdoc)
  * @see PreparedStatement::executePreparedStatement()
  */
 public function executePreparedStatement(array $data, $msg = '')
 {
     if (!$this->prepareStatementData($data, !empty($this->stmt) ? $this->stmt->param_count : 0, $msg)) {
         return false;
     }
     $this->preparedStatementResult = null;
     $res = $this->stmt->execute();
     return $this->finishStatement($res, $msg);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:13,代码来源:MysqliPreparedStatement.php

示例8: _execute

 /**
  * Executes a prepared statement.
  *
  * @param array $params OPTIONAL Values to bind to parameter placeholders.
  * @return bool
  * @throws Zend_Db_Statement_Mysqli_Exception
  */
 public function _execute(array $params = null)
 {
     if (!$this->_stmt) {
         return false;
     }
     // if no params were given as an argument to execute(),
     // then default to the _bindParam array
     if ($params === null) {
         $params = $this->_bindParam;
     }
     // send $params as input parameters to the statement
     if ($params) {
         array_unshift($params, str_repeat('s', count($params)));
         call_user_func_array(array($this->_stmt, 'bind_param'), $params);
     }
     // execute the statement
     $retval = $this->_stmt->execute();
     if ($retval === false) {
         /**
          * @see Zend_Db_Statement_Mysqli_Exception
          */
         require_once 'Zend/Db/Statement/Mysqli/Exception.php';
         throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement execute error : " . $this->_stmt->error);
     }
     // retain metadata
     if ($this->_meta === null) {
         $this->_meta = $this->_stmt->result_metadata();
         if ($this->_stmt->errno) {
             /**
              * @see Zend_Db_Statement_Mysqli_Exception
              */
             require_once 'Zend/Db/Statement/Mysqli/Exception.php';
             throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement metadata error: " . $this->_stmt->error);
         }
     }
     // statements that have no result set do not return metadata
     if ($this->_meta !== false) {
         // get the column names that will result
         $this->_keys = array();
         foreach ($this->_meta->fetch_fields() as $col) {
             $this->_keys[] = $this->_adapter->foldCase($col->name);
         }
         // set up a binding space for result variables
         $this->_values = array_fill(0, count($this->_keys), null);
         // set up references to the result binding space.
         // just passing $this->_values in the call_user_func_array()
         // below won't work, you need references.
         $refs = array();
         foreach ($this->_values as $i => &$f) {
             $refs[$i] =& $f;
         }
         $this->_stmt->store_result();
         // bind to the result variables
         call_user_func_array(array($this->_stmt, 'bind_result'), $this->_values);
     }
     return $retval;
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:64,代码来源:Mysqli.php

示例9: execute

 /**
  * @return Result
  */
 public function execute($params = [])
 {
     $params = $params ?: $this->params;
     $sql = $this->sql;
     if ($params) {
         $emulatedNamedParameters = false;
         if (array_values($params) != $params) {
             $emulatedNamedParameters = true;
         }
         if ($emulatedNamedParameters) {
             $actualParameters = [];
             $sql = preg_replace_callback('`:(\\w+)`', function ($matches) use(&$actualParameters, $params) {
                 $actualParameters[] = $params[$matches[1]];
                 return "?";
             }, $sql);
         } else {
             $actualParameters = $params;
         }
         $this->statement = $this->mysqli->prepare($sql);
         if ($this->statement === false) {
             throw new \InvalidArgumentException($this->mysqli->error);
         }
         foreach ($actualParameters as $parameter) {
             if (is_int($parameter)) {
                 $this->statement->bind_param('i', $parameter);
             } else {
                 if (is_double($parameter) || is_float($parameter)) {
                     $this->statement->bind_param('d', $parameter);
                 } else {
                     $this->statement->bind_param('s', $parameter);
                 }
             }
         }
     } else {
         $this->statement = $this->mysqli->prepare($sql);
         if ($this->statement === false) {
             throw new \InvalidArgumentException($this->mysqli->error);
         }
     }
     $this->statement->execute();
 }
开发者ID:jimbojsb,项目名称:dolphin,代码行数:44,代码来源:Statement.php

示例10: doLoginWithPostData

 private function doLoginWithPostData()
 {
     // check login form contents
     if (empty($_POST['email'])) {
         $this->errors[] = "Email field was empty.";
     } else {
         if (empty($_POST['password'])) {
             $this->errors[] = "Password field was empty.";
         } else {
             if (!empty($_POST['email']) && !empty($_POST['password'])) {
                 $this->db_connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
                 // change character set to utf8 and check it
                 if (!$this->db_connection->set_charset("utf8")) {
                     $this->errors[] = $this->db_connection->error;
                 }
                 // if no connection errors (= working database connection)
                 if (!$this->db_connection->connect_errno) {
                     // escape the POST stuff
                     $email = $this->db_connection->real_escape_string($_POST['email']);
                     // database query, getting all the info of the selected user (allows login via email address in the
                     // username field)
                     $sql = new mysqli_stmt($this->db_connection, "SELECT id, first_name, last_name, email, password, privilege FROM users WHERE email = ?;");
                     $sql->bind_param("s", $_POST['email']);
                     $sql->execute();
                     $result_of_login_check = $sql->get_result();
                     // if this user exists
                     if ($result_of_login_check->num_rows == 1) {
                         // get result row (as an object)
                         $result_row = $result_of_login_check->fetch_object();
                         // using PHP 5.5's password_verify() function to check if the provided password fits
                         // the hash of that user's password
                         if (password_verify($_POST['password'], $result_row->password)) {
                             // write user data into PHP SESSION (a file on your server)
                             $_SESSION['id'] = $result_row->id;
                             $_SESSION['first_name'] = $result_row->first_name;
                             $_SESSION['last_name'] = $result_row->last_name;
                             $_SESSION['email'] = $result_row->email;
                             //                        $_SESSION['privilege'] = $result_row->privilege;
                             $_SESSION['user_login_status'] = 1;
                             $this->messages[] = "You have logged in successfully!";
                         } else {
                             $this->errors[] = "Wrong password. Try again.";
                         }
                     } else {
                         $this->errors[] = "This user does not exist.";
                     }
                 } else {
                     $this->errors[] = "Database connection problem.";
                 }
             }
         }
     }
 }
开发者ID:spiotr12,项目名称:WonderBlog,代码行数:53,代码来源:Login.class.php

示例11: execute

 /**
  * Execute the prepared statement
  *
  * @param array    $parameters
  * @return \Attw\Db\Statement\MySQLiStatement
  */
 public function execute(array $parameters = array())
 {
     if (count($this->bindParam) > 0 || count($parameters) > 0) {
         $this->bindParamOfMySQLi($parameters);
     }
     $this->verifyMySQLiErrorsAndThrowException();
     if (!$this->stmt->execute()) {
         StatementException::mysqliStmtError($this->stmt->error, $this->stmt->errno);
     }
     $this->result = $this->stmt->get_result();
     return $this;
 }
开发者ID:attwframework,项目名称:framework,代码行数:18,代码来源:MySQLiStatement.php

示例12: execute

 /**
  * Выполняет запрос.
  *    
  * @return void
  */
 public function execute()
 {
     $types = str_split($this->debugTypes);
     $params = ['types' => $types, 'vars' => $this->debugVars];
     $sql = $this->createSqlString($params);
     $this->mysqli->autocommit(false);
     $this->mysqli->query($sql);
     $this->mysqli->rollback();
     if (empty($this->mysqli->error)) {
         $bindParams = $this->boundParams($params);
         call_user_func_array(['parent', 'bind_param'], $bindParams);
         parent::execute();
     }
 }
开发者ID:twin-ch,项目名称:abc-framework,代码行数:19,代码来源:Shaper.php

示例13: caricaIndirizzoDaStmt

 /**
  * Carica un indirizzo eseguendo un prepared statement
  * @param mysqli_stmt $stmt
  * @return null
  */
 public function caricaIndirizzoDaStmt(mysqli_stmt $stmt)
 {
     if (!$stmt->execute()) {
         error_log("[caricaIndirizzoDaStmt] impossibile" . " eseguire lo statement");
         return null;
     }
     $row = array();
     $bind = $stmt->bind_result($row['id'], $row['destinatario'], $row['via_num'], $row['citta'], $row['provincia'], $row['cap'], $row['telefono']);
     if (!$bind) {
         error_log("[caricaIndirizzoDaStmt] impossibile" . " effettuare il binding in output");
         return null;
     }
     if (!$stmt->fetch()) {
         return null;
     }
     $stmt->close();
     return self::creaIndirizzoDaArray($row);
 }
开发者ID:Artorias91,项目名称:Progetto-AMM,代码行数:23,代码来源:IndirizzoFactory.php

示例14: execute

 /**
  * {@inheritdoc}
  */
 public function execute($params = null)
 {
     if (null !== $this->_bindedValues) {
         if (null !== $params) {
             if (!$this->_bindValues($params)) {
                 throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
             }
         } else {
             if (!call_user_func_array(array($this->_stmt, 'bind_param'), $this->_bindedValues)) {
                 throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
             }
         }
     }
     if (!$this->_stmt->execute()) {
         throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
     }
     if (null === $this->_columnNames) {
         $meta = $this->_stmt->result_metadata();
         if (false !== $meta) {
             $columnNames = array();
             foreach ($meta->fetch_fields() as $col) {
                 $columnNames[] = $col->name;
             }
             $meta->free();
             $this->_columnNames = $columnNames;
             $this->_rowBindedValues = array_fill(0, count($columnNames), NULL);
             $refs = array();
             foreach ($this->_rowBindedValues as $key => &$value) {
                 $refs[$key] =& $value;
             }
             if (!call_user_func_array(array($this->_stmt, 'bind_result'), $refs)) {
                 throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
             }
         } else {
             $this->_columnNames = false;
         }
     }
     // We have a result.
     if (false !== $this->_columnNames) {
         $this->_stmt->store_result();
     }
     return true;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:46,代码来源:MysqliStatement.php

示例15: array

 /**
  * Carica una lista di articoli eseguendo un prepared statement
  * @param mysqli_stmt $stmt
  * @return null
  */
 public function &caricaArticoliDaStmt(mysqli_stmt $stmt)
 {
     $articoli = array();
     if (!$stmt->execute()) {
         error_log("[caricaArticoliDaStmt] impossibile" . " eseguire lo statement");
         return null;
     }
     $row = array();
     $bind = $stmt->bind_result($row['id'], $row['size'], $row['qty'], $row['prezzo'], $row['pizza_id']);
     if (!$bind) {
         error_log("[caricaArticoliDaStmt] impossibile" . " effettuare il binding in output");
         return null;
     }
     while ($stmt->fetch()) {
         $articoli[] = self::creaArticoloDaArray($row);
     }
     $stmt->close();
     return $articoli;
 }
开发者ID:Artorias91,项目名称:Progetto-AMM,代码行数:24,代码来源:ArticoloFactory.php


注:本文中的mysqli_stmt::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。