会话ID与表

时间:2016-04-29 06:06:25

标签: php sql codeigniter reporting-services

当Session StaffID与report表中的StaffID匹配时,我正尝试从reports检索所有报告。

Report_Name, ReportDate and ReportID are part of the report table

我认为这应该是

ReportID获取Report_NameReportDatereport ReportID Read_ReportReportID匹配report StaffID } 在StaffID

中的会话Read_Report = function get_read_report() { $this->db->select('report.Report_Name, report.ReportDate, report.ReportID') ->from('Read_Report') ->join('Read_Report', 'report.ReportID = Read_Report.ReportID') ->where('StaffID', $this->session->userdata("StaffID")); return $result = $this->db->get(); }

,这是我的查询

Not unique table/alias: 'Read_Report'

SELECT `report`.`Report_Name`, `report`.`ReportDate`, `report`.`ReportID` FROM `Read_Report` JOIN `Read_Report` ON

我收到此错误

  

错误号码:1066

report
     

ReportIDRead_Report = ReportIDStaffID WHERE Filename: models/report/Report_model.php Line Number: 91 ='3'

 function my_read_reports()
    {
        $data = array();

        if ($query = $this->report_model->get_read_report()) {
            $data['reports'] = $query;
        }

        $this->template['middle'] = $this->load->view($this->middle = 'pages/read_reports_view', $data, true);
        $this->layout();
    }

控制器代码

java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.

2 个答案:

答案 0 :(得分:3)

您需要将表与report表联系起来,而不是同一个表

更改

 ->join('Read_Report', 'report.ReportID = Read_Report.ReportID')

 ->join('report', 'report.ReportID = Read_Report.ReportID')

您需要将查询更改为

$this->db->select('report.Report_Name, report.ReportDate, report.ReportID')
            ->from('report')
            ->join('Read_Report', 'report.ReportID = Read_Report.ReportID')
            ->where('Read_Report.StaffID', $this->session->userdata("StaffID"));
         $result = $this->db->get();
         return $result->result();// fetch data then return

答案 1 :(得分:2)

您的查询应该是

 $this->db->select('report.Report_Name, report.ReportDate, report.ReportID')
        ->from('Read_Report')
        ->join('report', 'report.ReportID = Read_Report.ReportID')
        ->where('StaffID', $this->session->userdata("StaffID"));
        return $result = $this->db->get();