2013-05-28 14 views
0

我有這個查詢,我想讓它在codeigniter查詢表單中工作,所以想知道它的可能與否。codeigniter,使用情況何時用於查詢

這是我想用codeigniter自己的方式在Codeigniter中實現的查詢。

use zorkif_next; 
SELECT 
    `osp_job_status_track`.`StatusID`, 
    `osp_job_status_track`.`SubStatusID`, 
    `osp_job_sub_status`.`CurrentStatus` 
FROM 
    (`osp_job_details`) 
     LEFT JOIN 
    `osp_job_status_track` ON `osp_job_status_track`.`JobID` = `osp_job_details`.`JobID` 
     LEFT JOIN 
    `osp_job_status` ON `osp_job_status`.`StatusID` = `osp_job_status_track`.`StatusID` 
     LEFT JOIN 
    `osp_job_sub_status` ON `osp_job_sub_status`.`SubStatusID` = `osp_job_status_track`.`SubStatusID` 
     LEFT JOIN 
    `hr_employee_details` ON `hr_employee_details`.`EmployeeID` = `osp_job_details`.`AssignToEmployeeID` 
     LEFT JOIN 
    `osp_job_type` ON `osp_job_type`.`JobTypeID` = `osp_job_details`.`JobtypeID` 
WHERE 
    -- `isDefault` = 1 
     -- AND 

    CASE WHEN `osp_job_status`.`StatusID` = 2 
    THEN `osp_job_sub_status`.`CurrentStatus` = 3 
    ELSE `osp_job_status`.`StatusID` >= 2 
    END ; 

那麼如何實現

$this->db->where($where); 

這個查詢???

+0

沒有辦法在'CI'中實現'CASE'。 CI SQL庫很弱 – diEcho

+0

我不確定它在CI中是否可行。你可以去看看所有可用的主動rec ..檢查這個文件 - system \ database \ DB_active_rec.php –

+0

閱讀:http://stackoverflow.com/questions/11821503/does-codeigniter-datamapper-orm-support- a-mysql-case-statement-in-order-by-claus – diEcho

回答

0

在CI中不可能,您需要編寫自己的查詢。請看看這個文件。你可以看到所有可用的方法。

\system\database\DB_active_rec.php 
+1

也閱讀指南:http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html – diEcho

+0

因此,如果它不可能在codeigniters的方式,那麼如何實現它在簡單的方法在codeigniter像$ this-> db-> query('')?? –

+0

go throgh上面的文件並自己學習 –