I have a database table "transactions" which has a field "account". I want to retrieve a subset of all not-null account rows from the current set of data and have it as a virtualField I can access down the line in my view.
class Transaction extends AppModel {
public $virtualFields = array(
"Accounts" => $this->Transaction->find("all", array("conditions" => array("not" => array("Transaction.account" => null))))
);
}
So that I get an array of all transactions with non-null account fields named "Accounts".
This doesn't work - gives me "unexpected T_VARIABLE" error (doesn't like $this). I was trying to follow the guide here. I'm a moderate level PHP developer and this is my first real Cake project, so I may be going about this completely wrong.
When you're inside the model that you're querying, you don't specify the model name, just:
...so try this: