NativeQuery.php 1.03 KB
Newer Older
romanb's avatar
romanb committed
1 2
<?php 

3
namespace Doctrine\ORM;
romanb's avatar
romanb committed
4 5

/**
6 7 8
 * Represents a native SQL query.
 *
 * @since 2.0
romanb's avatar
romanb committed
9
 */
10
class NativeQuery
romanb's avatar
romanb committed
11 12 13 14 15
{
    private $_sql;
    private $_conn;
    private $_params = array();
    
16 17
    public function __construct($sql, Connection $conn)
    {        
romanb's avatar
romanb committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
        $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));
    }
}