Skip to content
Permalink
Browse files

Adding try catch for pdo exception on DboSource::_execute

  • Loading branch information...
lorenzo committed Nov 29, 2010
1 parent 130fe60 commit a79168778457bd6ee3c9bfab5458600c47152d05
Showing with 18 additions and 25 deletions.
  1. +0 −13 cake/libs/model/datasources/dbo/dbo_sqlite.php
  2. +18 −12 cake/libs/model/datasources/dbo_source.php
@@ -207,19 +207,6 @@ function describe(&$model) {
return $fields;
}
/**
* Executes given SQL statement.
*
* @param string $sql SQL statement
* @param array $params list of params to be bound to query
* @return PDOStatement if query executes with no problem, true as the result of a succesfull
* query returning no rows, suchs as a CREATE statement, false otherwise
*/
protected function _execute($sql, $params = array()) {
$this->_result = parent::_execute($sql, $params);
return $this->_result;
}
/**
* Generates and executes an SQL UPDATE statement for given model, fields, and values.
*
@@ -344,19 +344,25 @@ protected function _execute($sql, $params = array()) {
}
}
$query = $this->_connection->prepare($sql);
$query->setFetchMode(PDO::FETCH_LAZY);
if (!$query->execute($params)) {
$this->_results = $query;
$this->error = $this->lastError($query);
$query->closeCursor();
return false;
}
if (!$query->columnCount()) {
$query->closeCursor();
return true;
try {
$query = $this->_connection->prepare($sql);
$query->setFetchMode(PDO::FETCH_LAZY);
if (!$query->execute($params)) {
$this->_results = $query;
$this->error = $this->lastError($query);
$query->closeCursor();
return false;
}
if (!$query->columnCount()) {
$query->closeCursor();
return true;
}
return $query;
} catch (PDOException $e) {
$this->_results = null;
$this->error = $e->getMessage();
}
return $query;
}
/**

0 comments on commit a791687

Please sign in to comment.
You can’t perform that action at this time.