Actual CJoinElement.buildQuery looks like this
public function buildQuery($query)
{
foreach($this->children as $child)
{
if($child->relation instanceof CHasOneRelation || $child->relation instanceof CBelongsToRelation
|| $this->_finder->joinAll || !$this->_finder->baseLimited && $child->relation->together)
{
$child->_joined=true;
$query->join($child);
$child->buildQuery($query);
}
}
}
why are "has many" relationships excluded?
I mean, if I have say a blog post, that can have many categories, and the relation is called "categories", if i do
$criteria->with['categories'] = Array("select"=>"category_id");
$criteria->addCondition("categories.category_id", 1);
$Post::model()->findAll($criteria);
"categories" is stripped out from the query and i (obviously) get the error
“Unknown column ‘categories.category_id’ in ‘where clause’”.
if changed buildQuery in
public function buildQuery($query)
{
foreach($this->children as $child)
{
if($child->relation instanceof CHasOneRelation || $child->relation instanceof CBelongsToRelation
|| $child->relation instanceof CHasManyRelation // join HasMany relationships
|| $this->_finder->joinAll || !$this->_finder->baseLimited && $child->relation->together)
{
$child->_joined=true;
$query->join($child);
$child->buildQuery($query);
}
}
}
and it works without problems.
Is there a reason why they were removed?
Am I missing something?