我試着去實現與LEFT刪除代碼加入的Joomla 2.5:的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查詢?有任何想法嗎?
嘗試鏈接 - >列(t1。*,t2。*)刪除很奇怪,因爲它顯然只放置表。 – Elin
不,這也行不通。 – Bounce
如果你做$ query-> delete()它會刪除整行。剛好在JTableUser $ query-> delete()中看到了這一點。查詢 - >從( '#__ user_usergroup_map'); – Elin