1

I am trying to retrieve a list of id's with a friendly_name (a virtualField in a model), but I keep on getting a unknown column on the virtual field. Any ideas?

  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"
                        )
                    )
                );
mauzilla
  • 3,574
  • 10
  • 50
  • 86

1 Answers1

1

Where is that Virtual Field specified, Re or ReAgent?

If it's in the Re model, then remove the "fields" param to the ReAgent model in the contain (which should be singular by the way)...

$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",
        )
    )
);

You also had ReAgent outside of your contain, that isn't going to help! The above sample is cleaned up.

ianmjones
  • 3,395
  • 1
  • 25
  • 26