コード例 #1
0
 /**
  * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
  * and returns the number of affected rows.
  *
  * This method supports PDO binding types as well as DBAL mapping types.
  *
  * @param string $query The SQL query.
  * @param array $params The query parameters.
  * @param array $types The parameter types.
  * @return integer The number of affected rows.
  * @internal PERF: Directly prepares a driver statement, not a wrapper.
  */
 public function executeUpdate($query, array $params = array(), array $types = array())
 {
     $this->connect();
     $hasLogger = $this->_config->getSQLLogger() !== null;
     if ($hasLogger) {
         $this->_config->getSQLLogger()->startQuery($query, $params, $types);
     }
     if ($params) {
         list($query, $params, $types) = SQLParserUtils::expandListParameters($query, $params, $types);
         $stmt = $this->_conn->prepare($query);
         if ($types) {
             $this->_bindTypedValues($stmt, $params, $types);
             $stmt->execute();
         } else {
             $stmt->execute($params);
         }
         $result = $stmt->rowCount();
     } else {
         $result = $this->_conn->exec($query);
     }
     if ($hasLogger) {
         $this->_config->getSQLLogger()->stopQuery();
     }
     return $result;
 }
コード例 #2
0
 /**
  * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
  * and returns the number of affected rows.
  * 
  * This method supports PDO binding types as well as DBAL mapping types.
  *
  * @param string $query The SQL query.
  * @param array $params The query parameters.
  * @param array $types The parameter types.
  * @return integer The number of affected rows.
  * @internal PERF: Directly prepares a driver statement, not a wrapper.
  */
 public function executeUpdate($query, array $params = array(), array $types = array())
 {
     $this->connect();
     if ($this->_config->getSQLLogger() !== null) {
         $this->_config->getSQLLogger()->logSQL($query, $params);
     }
     if ($params) {
         $stmt = $this->_conn->prepare($query);
         if ($types) {
             $this->_bindTypedValues($stmt, $params, $types);
             $stmt->execute();
         } else {
             $stmt->execute($params);
         }
         $result = $stmt->rowCount();
     } else {
         $result = $this->_conn->exec($query);
     }
     return $result;
 }