gpt4 book ai didi

mysql - 在 Symfony 中打印 Sql 查询

转载 作者:行者123 更新时间:2023-11-29 03:56:41 26 4
gpt4 key购买 nike

我需要找出下面的正常 sql 查询。你们能建议我如何在 Symfony 中实现吗? 示例:

 $r = Doctrine_Query::create()
->select('u.worked_hours')
->from('tasksComments u')
->where('u.tasks_id = ?', $arr_values['tasks_id'])
->andwhere('u.id != ?', $arr_values['id'])
->andwhere('u.created_at LIKE ?', $date."%");
$results1 = $r->execute();

最佳答案

在查询对象上,使用方法getSQL

在你的情况下:

$r = Doctrine_Query::create()
->select('u.worked_hours')
->from('tasksComments u')
->where('u.tasks_id = ?', $arr_values['tasks_id'])
->andwhere('u.id != ?', $arr_values['id'])
->andwhere('u.created_at LIKE ?', $date."%");

var_dump($r->getSQL()); // print the SQL query - you will need to replace the parameters in the query
var_dump($r->getParams()); // print the parameters of the query so you can easily replace the missing parameters in the query

请注意,我不知道 Doctrine_Query 的 namespace ,但我假设您的 Query 对象在这个 Query object in the Doctrine API documentation 中.

关于mysql - 在 Symfony 中打印 Sql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19408850/

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