2 questions about model relations


I have 2 questions:

  1. Can i set a condition in a relation query in model? For example, queries for parent elements are generating by getParent() method.

They include queries in case where parent_id = 0 (which not exists). How can i avoid this?

  1. How can i get that object is a "relation"-object in model? I mean, i need to know was object found by direct Model::find() method or it was get by $model->parent query? Is it possible?