Joomla Development Database选择Query Giving Not unique table / alias

时间:2016-01-08 07:44:30

标签: mysql database joomla3.0 joomla-extensions

我正在开发一个Joomla 3组件,我正在尝试使用Joomla框架类从数据库中选择数据。我收到错误不唯一的表/别名。可能是什么原因?。

代码段......

$app = JFactory::getApplication();
        $job_id = JRequest::getVar('Jobid', null);
        try {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);//Here Was The Problem
            $query->select(array('A.state AS approval_state', 'A.*', 'B.*', 'C.district_name', 'D.educational_qualification', 'E.current_job_status'))
                    ->from($db->quoteName('#__pes_job_provider_request_cv_info') . 'AS A')
                    ->join('LEFT', '#__pes_jobseeker_profile AS B ON B.jobseeker_profile_id = A.jobseeker_profile_id')
                    ->join('LEFT', '#__pes_district AS C ON C.district_id = A.district_id')
                    ->join('LEFT', '#__pes_highest_educational_qualification AS D ON D.highest_educational_qualification_id = B.highest_educational_qualification_id')
                    ->join('LEFT', '#__pes_current_job_status AS E ON E.current_job_status_id = B.current_job_status_id')
                    ->where($db->quoteName('A.job_order_registration_id') . ' = ' . $db->quote($job_id))
                    ->order('B.name_in_full ASC');
            $db->setQuery($query);
            $results = $db->loadObjectList();

谢谢。

1 个答案:

答案 0 :(得分:2)

好的!我弄明白了原因。

之所以发生这种情况,是因为我没有将查询对象实例化为新查询。

i.e. $query = $db->getQuery();

因此,为了解决这个问题,我只是为查询方法

提供了参数boolean true
i.e. $query = $db->getQuery(true);