无法在Symfony中创建包含JOIN和RAND()的MySQL查询 [英] Trouble creating MySQL query in Symfony containing JOIN and RAND()
本文介绍了无法在Symfony中创建包含JOIN和RAND()的MySQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该怎么做:
SELECT t.id
FROM table t
JOIN (SELECT(FLOOR(max(id) * rand())) AS maxid FROM table)
AS tt
ON t.id >= tt.maxid
LIMIT 1
在Symfony中? (我知道如何做基本的事情,但这太多了.
in Symfony? (I know how to do basic stuff, but this is too much.
推荐答案
$connection = Doctrine_Manager::getConnection()->getDbh();
不起作用...请尝试以下操作:
won't work... Try this:
$connection = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh();
然后:
$stmt = $connection->query('SELECT * FROM some_table');
$stmt->execute();
$result = $stmt->fetchAll();
这篇关于无法在Symfony中创建包含JOIN和RAND()的MySQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文