我试图在 Joomla 2.5 中使用 LEFT JOIN 实现删除代码:
$cid = JRequest::getVar('cid', array(), 'post', 'array');
$query = $db->getQuery(true);
$query->delete($db->quoteName('table1').' AS t1');
$query->leftJoin($db->quoteName('table2').
' AS t2 ON t2.table_1_id = t1.id ');
$query->where(array('t1.id IN ('. implode(',', $cid).')'));
$db->setQuery($query);
try {
$db->query();
} catch (Exception $e) {
echo $e->getMessage();
}
我得到的是:
DELETE FROM `table1` AS t1
LEFT JOIN `table2` AS t2 ON t2.table_1_id = t1.id
WHERE t1.id IN (48)
此 SQL 查询不正确。我需要的是:
DELETE t1.*,t2.* FROM `table1` AS t1
LEFT JOIN `table2` AS t2 ON t2.table_1_id = t1.id
WHERE t1.id IN (48)
那么我应该如何更改 Joomla 查询以获得正确的 SQL 查询呢?有任何想法吗?