问号DQL是不是没有考虑?

发布于 2024-11-16 23:05:09 字数 839 浏览 5 评论 0原文

我有以下 DQL 查询:

$query = Doctrine_Query::create()
                ->select('p.genre')
                ->from('Profile p')
                ->where('sf_guard_user_id = ?',  11);

如果我使用 $sql = $query->getSqlQuery(); 返回 SQL 语法,我得到:

SELECT p.id AS p__id, p.genre AS p__genre FROM profile p WHERE (p.sf_guard_user_id = ?)

这不正常。它应该是11而不是

SELECT p.id AS p__id, p.genre AS p__genre FROM profile p WHERE (p.sf_guard_user_id = 11)

如果我写:

$query = Doctrine_Query::create()
                ->select('p.genre')
                ->from('Profile p')
                ->where('sf_guard_user_id = ' .  11);

SQL语法是正确的。

通常,DQL 应自动执行此操作。为什么没有发生?

I have the following DQL query:

$query = Doctrine_Query::create()
                ->select('p.genre')
                ->from('Profile p')
                ->where('sf_guard_user_id = ?',  11);

If I return the SQL syntax with $sql = $query->getSqlQuery(); I get:

SELECT p.id AS p__id, p.genre AS p__genre FROM profile p WHERE (p.sf_guard_user_id = ?)

This is not normal. It should be 11 not ?:

SELECT p.id AS p__id, p.genre AS p__genre FROM profile p WHERE (p.sf_guard_user_id = 11)

And if I write:

$query = Doctrine_Query::create()
                ->select('p.genre')
                ->from('Profile p')
                ->where('sf_guard_user_id = ' .  11);

The SQL syntax is correct.

Normally DQL should do this automatically. Why isn't happening ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹过旳痕迹 2024-11-23 23:05:09

这就是准备好的语句的工作原理。值将绑定在数据库服务器上,因此学说无法通过查询显示真实值。

如果您使用准备好的语句而不是真正的值,学说将显示一个问号。

此处查看其描述方式

This is how prepared statement works. Values will be bound on database server Hence doctrine can not show the real values with the query.

Doctrine will show a question mark if you use prepared statement not the real value.

Checkout how it is describing here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文