Sequenzia/lib/Rails/ActiveRecord/Exception/QueryAwareTrait.php
2013-10-02 11:14:53 -05:00

28 lines
588 B
PHP
Executable File

<?php
namespace Rails\ActiveRecord\Exception;
trait QueryAwareTrait
{
protected $stmt;
protected $values;
public function setStatement(\PDOStatement $stmt, array $values = [])
{
$this->stmt = $stmt;
$this->values = $values;
return $this;
}
public function postMessage()
{
$msg = '';
if ($this->stmt) {
$msg .= "\nQuery: " . $this->stmt->queryString;
if ($this->values)
$msg .= "\nValues: " . var_export($this->values, true);
}
return $msg;
}
}