On a site that I have been working on for a long time, I suddenly came across this issue. When I went to com_plugins to change settings on my plugins, I got the error below and the plugins list didn't show.
Error
Column 'type' in where clause is ambiguous
SQL=SELECT COUNT(*) FROM `#__extensions` AS a LEFT JOIN #__users AS uc ON uc.id=a.checked_out LEFT JOIN #__viewlevels AS ag ON ag.id = a.access WHERE `type` = 'plugin' AND (a.enabled IN (0, 1)) AND a.state >= 0
Column 'type' in where clause is ambiguous
SQL=SELECT a.extension_id , a.name, a.element, a.folder, a.checked_out, a.checked_out_time, a.enabled, a.access, a.ordering,uc.name AS editor,ag.title AS access_level FROM `#__extensions` AS a LEFT JOIN #__users AS uc ON uc.id=a.checked_out LEFT JOIN #__viewlevels AS ag ON ag.id = a.access WHERE `type` = 'plugin' AND (a.enabled IN (0, 1)) AND a.state >= 0 ORDER BY `folder` asc,a.ordering ASC LIMIT 0, 20
Column 'type' in where clause is ambiguous
SQL=SELECT COUNT(*) FROM `#__extensions` AS a LEFT JOIN #__users AS uc ON uc.id=a.checked_out LEFT JOIN #__viewlevels AS ag ON ag.id = a.access WHERE `type` = 'plugin' AND (a.enabled IN (0, 1)) AND a.state >= 0
The where type= 'plugin'
clause is ambiguous.
I checked the plugins model of the com_plugins in a clean joomla installation, as well as in a few older versions of J3. The part of the code in question is at about line 211, in the getListQuery()
method.
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.extension_id , a.name, a.element, a.folder, a.checked_out, a.checked_out_time,' .
' a.enabled, a.access, a.ordering'
)
)
->from($db->quoteName('#__extensions') . ' AS a')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
All installations come like this and the strange thing is that it was always working fine in any Joomla site, but suddenly not on this one.
Running the same query directly in Joomla databases, it works for other Joomla db installations but not on this one, where it also gives the same error about the ambiguous column 'type' in the where.
Changing the query in the method from where type = 'plugin'
to where a.type = 'plugin'
, which makes sense since this is a joined list, and this way the type field is referencing its table, the issue is gone.
Has anyone notice this kind of issue with the com_plugins?