2011-06-15 44 views
2

我有我的活動記錄查詢中的特定問題。使用像加入代碼點火器活動記錄

當我使用join('users parent', 'child.treePath LIKE CONCAT(parent.treePath,"%")') 代碼點火器吐出JOIN 'users' parent ON 'child'.'treePath' 'LIKE' CONCAT(parent.treePath,"%")(請注意,我已經更換了所有反勾(`)與(')由於降價:/)

所以,問題是代碼點火器包裝如(`)。

如何告訴它而不是嘗試格式化此塊?


完整的查詢:

$this->db->select('child.uuid') 
     ->from('users child') 
     ->join('users parent', 'child.treePath LIKE CONCAT(parent.treePath,"%")') 
     ->where('parent.uuid', $uuid) 
     ->where("LENGTH(REPLACE(child.treePath, parent.treePath, '')) - LENGTH(REPLACE(REPLACE(child.treePath, parent.treePath, ''), '/', '')) <= ", $levels, 'false') 
     ->where("LENGTH(REPLACE(child.treePath, parent.treePath, '')) - LENGTH(REPLACE(REPLACE(child.treePath, parent.treePath, ''), '/', '')) > ", 0, 'false') 
     ->group_by('child.treeId'); 

回答

3

如果你是在一個單一的通話鏈接所有這些功能結合在一起,你可能也只是使用

$this->db->query("Write all your specific SQL here"); 

沒有看到摔跤與笨的好處查詢生成器在你的情況。

+0

只記得當你沒有使用CI的活動記錄時,你應該使用mysql_real_escape_string()任何用戶輸入 – 2011-06-15 20:42:52