无法在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中? (我知道该怎么做,但这太多了.
解决方法:
$connection = Doctrine_Manager::getConnection()->getDbh();
将无法正常工作…请尝试以下操作:
$connection = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh();
然后:
$stmt = $connection->query('SELECT * FROM some_table');
$stmt->execute();
$result = $stmt->fetchAll();
标签:symfony-1-4,sql,mysql 来源: https://codeday.me/bug/20191010/1883408.html