gpt4 book ai didi

php - 我需要将 SQL native 放在查询生成器 Doctrine2 中

转载 作者:搜寻专家 更新时间:2023-10-31 20:46:37 24 4
gpt4 key购买 nike

我需要在查询生成器原则 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;

关于php - 我需要将 SQL native 放在查询生成器 Doctrine2 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12436312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com