我需要将SQL本机放在查询生成器Doctrine2中
作者:互联网
我需要在查询生成器准则2中使用SQL NATIVE来使用SQL函数(CONCAT,REPLACE,LDAP).请帮我.
解决方法:
您可以尝试:
$connection = $this->get('doctrine')->getConnection();
$toto = "toto";
$foo = "foo";
$params = array('param1' => $toto, 'param2' => $foo);
$request = "SELECT * FROM table WHERE param1 = :param1 AND param2 = :param2";
try {
$stmt = $connection->executeQuery($request, $params);
} catch (\PDOException $e) {
// echo $e->getMessage();
}
while (($result = $stmt->fetch(\PDO::FETCH_ASSOC))) {
// stuff with $result
}
如果要对服务进行此类请求,则可能需要:
use Doctrine\DBAL\Connection;
标签:doctrine-orm,query-builder,symfony,php 来源: https://codeday.me/bug/20191127/2075741.html