2012-09-05 69 views
1

我想用friendly_name(模型中的虛擬字段)檢索id的列表,但我一直在虛擬字段上獲取未知列。有任何想法嗎?無法檢索包含容器中的虛擬字段cakephp

public $virtualFields = array(
     'friendly_name' => "CONCAT(ReAgent.first_name, ' ',ReAgent.last_name)" 
); 

$results = $this->Re->find("all", 
       array("recursive" => 0, 
        "fields" => array("Re.id","ReAgent.friendly_name"), 
        "contains" => array(
         "RegroupsRe" => 
          array("conditions" => 
           array(
            "regroup_id" => $post[$field] 
           ) 
          ) 
         ), 
         "ReAgent" => array(
          "fields" => "friendly_name" 
         ) 
        ) 
       ); 

回答

1

哪裏是虛擬字段指定Re或ReAgent?

如果它在重新模型,然後刪除「域」參數在含有(這應該是由奇路)...

$results = $this->Re->find(
    "all", 
    array(
     "recursive" => 0, 
     "fields" => array("Re.id", "ReAgent.friendly_name"), 
     "contain" => array(
      "RegroupsRe" => array(
       "conditions" => array(
        "regroup_id" => $post[$field] 
       ), 
      ), 
      "ReAgent", 
     ) 
    ) 
); 

也有試劑以外的試劑模型你的遏制,這不會幫助!上述樣品已清理完畢。