2013-04-07 74 views

回答

1

一般来说,ORM处理所有的转义。除非你传递原始的SQL查询,否则你应该没有逃避你的输入。为了证实,我通过Laravel代码挖,和整个​​方法,它的确利用PDO::prepare传来:

/** laravel/database/connection.php, lines 219-278 */ 
protected function execute($sql, $bindings = array()) 
{ 
    /* ... */ 
    try 
    { 
     $statement = $this->pdo->prepare($sql); 

     $start = microtime(true); 

     $result = $statement->execute($bindings); 
    } 
    // If an exception occurs, we'll pass it into our custom exception 
    // and set the message to include the SQL and query bindings so 
    // debugging is much easier on the developer. 
    catch (\Exception $exception) 
    { 
     $exception = new Exception($sql, $bindings, $exception); 

     throw $exception; 
    } 
    /* ... */ 
} 
+0

我从来没有使用原始查询。在最坏的情况下,我将它用于?的并将值绑定到?的。非常感谢您的回复。 – Aristona 2013-04-08 00:07:00