2008-09-12 16:28:36 +04:00
|
|
|
<?php
|
|
|
|
|
2009-02-17 13:54:18 +03:00
|
|
|
namespace Doctrine\ORM;
|
2008-09-12 16:28:36 +04:00
|
|
|
|
|
|
|
/**
|
2009-02-17 13:54:18 +03:00
|
|
|
* Represents a native SQL query.
|
|
|
|
*
|
|
|
|
* @since 2.0
|
2008-09-12 16:28:36 +04:00
|
|
|
*/
|
2009-02-17 13:54:18 +03:00
|
|
|
class NativeQuery
|
2008-09-12 16:28:36 +04:00
|
|
|
{
|
|
|
|
private $_sql;
|
|
|
|
private $_conn;
|
|
|
|
private $_params = array();
|
|
|
|
|
2009-02-17 13:54:18 +03:00
|
|
|
public function __construct($sql, Connection $conn)
|
|
|
|
{
|
2008-09-12 16:28:36 +04:00
|
|
|
$this->_sql = $sql;
|
|
|
|
$this->_conn = $conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*public function addScalar()
|
|
|
|
{
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
public function addEntity($alias, $className)
|
|
|
|
{
|
|
|
|
$this->_entities[$alias] = $className;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addJoin($join)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setParameter($key, $value)
|
|
|
|
{
|
|
|
|
$this->_params[$key] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function execute(array $params)
|
|
|
|
{
|
|
|
|
if ($this->_entities) {
|
|
|
|
//...
|
|
|
|
} else {
|
|
|
|
return $this->_conn->execute($this->_sql, array_merge($this->_params, $params));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function executeUpdate(array $params)
|
|
|
|
{
|
|
|
|
return $this->_conn->exec($this->_sql, array_merge($this->_params, $params));
|
|
|
|
}
|
|
|
|
}
|