示例#1
0
文件: Statement.php 项目: swk/bluebox
 /**
  * execute
  * Executes a prepared statement
  *
  * If the prepared statement included parameter markers, you must either:
  * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  * bound variables pass their value as input and receive the output value,
  * if any, of their associated parameter markers or pass an array of input-only
  * parameter values
  *
  *
  * @param array $params             An array of values with as many elements as there are
  *                                  bound parameters in the SQL statement being executed.
  * @return boolean                  Returns TRUE on success or FALSE on failure.
  */
 public function execute($params = null)
 {
     try {
         $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
         $this->_conn->getListener()->preStmtExecute($event);
         $result = true;
         if (!$event->skipOperation) {
             if ($this->_conn->getAttribute(Doctrine::PORTABILITY_EMPTY_TO_NULL)) {
                 foreach ($params as $key => $value) {
                     if ($value == '') {
                         $params[$key] = null;
                     }
                 }
             }
             $result = $this->_stmt->execute($params);
             $this->_conn->incrementQueryCount();
         }
         $this->_conn->getListener()->postStmtExecute($event);
         return $result;
     } catch (PDOException $e) {
     } catch (Doctrine_Adapter_Exception $e) {
     }
     $this->_conn->rethrowException($e, $this);
     return false;
 }
示例#2
0
 /**
  * execute
  * Executes a prepared statement
  *
  * If the prepared statement included parameter markers, you must either:
  * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  * bound variables pass their value as input and receive the output value,
  * if any, of their associated parameter markers or pass an array of input-only
  * parameter values
  *
  *
  * @param array $params             An array of values with as many elements as there are
  *                                  bound parameters in the SQL statement being executed.
  * @return boolean                  Returns TRUE on success or FALSE on failure.
  */
 public function execute($params = null)
 {
     $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
     $this->_conn->getListener()->preExecute($event);
     if (!$event->skipOperation) {
         $this->_stmt->execute($params);
         $this->_conn->incrementQueryCount();
     }
     $this->_conn->getListener()->postExecute($event);
     return $this;
 }
示例#3
0
 /**
  * execute
  * Executes a prepared statement
  *
  * If the prepared statement included parameter markers, you must either:
  * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  * bound variables pass their value as input and receive the output value,
  * if any, of their associated parameter markers or pass an array of input-only
  * parameter values
  *
  *
  * @param array $params             An array of values with as many elements as there are
  *                                  bound parameters in the SQL statement being executed.
  * @return boolean                  Returns TRUE on success or FALSE on failure.
  */
 public function execute($params = null)
 {
     try {
         $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
         $this->_conn->getListener()->preStmtExecute($event);
         $result = true;
         if (!$event->skipOperation) {
             $result = $this->_stmt->execute($params);
             $this->_conn->incrementQueryCount();
         }
         $this->_conn->getListener()->postStmtExecute($event);
         return $result;
     } catch (PDOException $e) {
     } catch (Doctrine_Adapter_Exception $e) {
     }
     $this->_conn->rethrowException($e, $this);
     return false;
 }
示例#4
0
 /**
  * execute
  * Executes a prepared statement
  *
  * If the prepared statement included parameter markers, you must either:
  * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  * bound variables pass their value as input and receive the output value,
  * if any, of their associated parameter markers or pass an array of input-only
  * parameter values
  *
  *
  * @param array $params             An array of values with as many elements as there are
  *                                  bound parameters in the SQL statement being executed.
  * @return boolean                  Returns TRUE on success or FALSE on failure.
  */
 public function execute($params = null)
 {
     try {
         $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
         $this->_conn->getListener()->preStmtExecute($event);
         $result = true;
         if (!$event->skipOperation) {
             if ($this->_conn->getAttribute(Doctrine_Core::ATTR_PORTABILITY) & Doctrine_Core::PORTABILITY_EMPTY_TO_NULL) {
                 foreach ($params as $key => $value) {
                     if ($value === '') {
                         $params[$key] = null;
                     }
                 }
             }
             if ($params) {
                 $pos = 0;
                 foreach ($params as $key => $value) {
                     $pos++;
                     $param = is_numeric($key) ? $pos : $key;
                     if (is_resource($value)) {
                         $this->_stmt->bindParam($param, $params[$key], Doctrine_Core::PARAM_LOB);
                     } else {
                         $this->_stmt->bindParam($param, $params[$key]);
                     }
                 }
             }
             $result = $this->_stmt->execute();
             $this->_conn->incrementQueryCount();
         }
         $this->_conn->getListener()->postStmtExecute($event);
         //fix a possible "ORA-01000: maximum open cursors exceeded" when many non-SELECTs are executed and the profiling is enabled
         if ('Oracle' == $this->getConnection()->getDriverName()) {
             $queryBeginningSubstring = strtoupper(substr(ltrim($this->_stmt->queryString), 0, 6));
             if ($queryBeginningSubstring != 'SELECT' && substr($queryBeginningSubstring, 0, 4) != 'WITH') {
                 $this->closeCursor();
             }
         }
         return $result;
     } catch (PDOException $e) {
     } catch (Doctrine_Adapter_Exception $e) {
     }
     $this->_conn->rethrowException($e, $this);
     return false;
 }
示例#5
0
 /**
  * execute
  * Executes a prepared statement
  *
  * If the prepared statement included parameter markers, you must either:
  * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  * bound variables pass their value as input and receive the output value,
  * if any, of their associated parameter markers or pass an array of input-only
  * parameter values
  *
  *
  * @param array $params             An array of values with as many elements as there are
  *                                  bound parameters in the SQL statement being executed.
  * @return boolean                  Returns TRUE on success or FALSE on failure.
  */
 public function execute($params = null)
 {
     try {
         $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
         $this->_conn->getListener()->preStmtExecute($event);
         $result = true;
         if (!$event->skipOperation) {
             if ($this->_conn->getAttribute(Doctrine_Core::ATTR_PORTABILITY) & Doctrine_Core::PORTABILITY_EMPTY_TO_NULL) {
                 foreach ($params as $key => $value) {
                     if ($value === '') {
                         $params[$key] = null;
                     }
                 }
             }
             if ($params) {
                 $pos = 0;
                 foreach ($params as $key => $value) {
                     if ($value === null) {
                         continue;
                     }
                     $pos++;
                     $param = is_numeric($key) ? $pos : $key;
                     if (is_resource($value)) {
                         $this->_stmt->bindParam($param, $params[$key], Doctrine_Core::PARAM_LOB);
                     } else {
                         $this->_stmt->bindParam($param, $params[$key]);
                     }
                 }
             }
             $result = $this->_stmt->execute();
             $this->_conn->incrementQueryCount();
         }
         $this->_conn->getListener()->postStmtExecute($event);
         return $result;
     } catch (PDOException $e) {
     } catch (Doctrine_Adapter_Exception $e) {
     }
     $this->_conn->rethrowException($e, $this);
     return false;
 }