【问题标题】:Joomla Development Database Select Query Giving Not unique table/aliasJoomla 开发数据库选择查询给定不是唯一的表/别名
【发布时间】:2016-01-08 07:44:30
【问题描述】:

我正在开发一个 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();

谢谢。

【问题讨论】:

  • 你是如何从数据库中获得select 的?请在您的问题中包含该代码 sn-p。
  • 刚刚添加了代码片段

标签: mysql database joomla3.0 joomla-extensions


【解决方案1】:

好的!我找到了原因。

发生这种情况的原因是我没有将查询对象实例化为新查询。

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

所以,为了解决这个问题,我只是简单地将参数 boolean true 用于查询方法

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多