Impriving documentation

This commit is contained in:
José Lorenzo Rodríguez 2010-10-17 11:28:11 -04:30
parent 7e2fe43ee3
commit c016f1d97b
2 changed files with 9 additions and 9 deletions

View file

@ -267,17 +267,15 @@ class DboMysql extends DboSource {
/**
* Returns a formatted error message from previous database operation.
*
* @param PDOStatement $query the query to extract the error from if any
* @return string Error message with error number
*/
function lastError() {
if ($this->hasResult()) {
$error = $this->_result->errorInfo();
if (empty($error)) {
$error;
}
return $error[1] . ': ' . $error[2];
function lastError(PDOStatement $query = null) {
$error = $query->errorInfo();
if (empty($error[2])) {
return null;
}
return null;
return $error[1] . ': ' . $error[2];
}
/**

View file

@ -242,6 +242,7 @@ class DboSource extends DataSource {
public function execute($sql, $options = array(), $params = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);
$this->error = null;
$t = microtime(true);
$this->_result = $this->_execute($sql, $params);
@ -274,7 +275,8 @@ class DboSource extends DataSource {
$query = $this->_connection->prepare($sql);
$query->setFetchMode(PDO::FETCH_LAZY);
if (!$query->execute($params)) {
$this->error = $this->lastError();
$this->_results = $query;
$this->error = $this->lastError($query);
return false;
}
if (!$query->columnCount()) {