1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 14:16:39 +02:00

__toString() do not throw an exception [Closes #19]

This commit is contained in:
David Grudl
2012-01-19 02:25:30 +01:00
parent bf49cec002
commit 3f2e383b47
2 changed files with 16 additions and 8 deletions

View File

@@ -285,13 +285,17 @@ class DibiDataSource extends DibiObject implements IDataSource
*/
public function __toString()
{
return $this->connection->translate('
SELECT %n', (empty($this->cols) ? '*' : $this->cols), '
FROM %SQL', $this->sql, '
%ex', $this->conds ? array('WHERE %and', $this->conds) : NULL, '
%ex', $this->sorting ? array('ORDER BY %by', $this->sorting) : NULL, '
%ofs %lmt', $this->offset, $this->limit
);
try {
return $this->connection->translate('
SELECT %n', (empty($this->cols) ? '*' : $this->cols), '
FROM %SQL', $this->sql, '
%ex', $this->conds ? array('WHERE %and', $this->conds) : NULL, '
%ex', $this->sorting ? array('ORDER BY %by', $this->sorting) : NULL, '
%ofs %lmt', $this->offset, $this->limit
);
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
}

View File

@@ -434,7 +434,11 @@ class DibiFluent extends DibiObject implements IDataSource
*/
final public function __toString()
{
return $this->connection->translate($this->_export());
try {
return $this->connection->translate($this->_export());
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
}