<?php
namespace boru\ai\Persistence\Db;

class DbQueryException extends \RuntimeException
{
    /** @var string */
    protected $sql;

    /** @var array */
    protected $params = array();

    /** @var string|null */
    protected $interpolatedSql;

    public function __construct($message, $code = 0, $sql = '', array $params = array(), $interpolatedSql = null, $previous = null)
    {
        parent::__construct((string)$message, (int)$code, $previous);
        $this->sql = (string)$sql;
        $this->params = $params;
        $this->interpolatedSql = $interpolatedSql !== null ? (string)$interpolatedSql : null;
    }

    public function sql()
    {
        return $this->sql;
    }

    public function params()
    {
        return $this->params;
    }

    public function interpolatedSql()
    {
        return $this->interpolatedSql;
    }
}
