I want to have a join like this:
$sql = new Sql($this->adapter);
$select = $sql->select();
$select->from(array('E' => 'Emails'));
$emailField =
$select->join(array('F' => 'EntityFiles'), "F.RelatedEntityId = E.EmailId AND F.RelatedEntityType = 'email'", array('FileName' => 'Name'), $select::JOIN_LEFT);
But when I try to run it I get an error saying Unknown column '"email
"' in 'on clause'.
How can I get it to work?
The second argument of the join method is the ON clause. So you have to set only the relation between your entities in this ON clause
You want to filter your results on this condition F.RelatedEntityType = 'email'.
Filtering must be in a WHERE clause. So just add a where clause with this condition.
Hope this helps.
Mohamed.