Model navigation properties

Hi,

I have three entities in my DB:

robot <<------->> charateristic_value <<------->> charateristic

<<-------->> means many-to-many.

The DB schema for this is:

  • Table: robot
  • Table: robotcharateristicvalue (many-to-many between robot and charateristic_value)
  • Table: charateristic_value
  • Table: charateristiccharateristicvalue (many-to-many between charateristic and charateristic_value)
  • Table: charateristic

The Models, with all hasManyToMany and belgonsTo configurated in their initialize methods, are:

  • Robot
  • RobotCharateristicValue
  • CharateristicValue
  • CharateristicCharateristicValue
  • Charateristic

I am inside Robot model. I'm implementing a Method that returns all Charateristic of this Robot with charateristic_name = "COLOR". I'd like to do something like that:

    $this->RobotCharateristicValue->CharateristicValue->CharateristicCharateristicValue->Charateristic(array(
         'CharateristicName = "EYE"',
     ));

Is there any way to do something like that? Or is it necessary to use the ::query() method?

Thank you.



30.7k

Hi,

Unfortunately, this nice feature (called "named scope" by yii framework: http://www.yiiframework.com/doc/guide/1.1/en/database.ar#named-scopes) is not available in phalcon, you will have to do it by hand in your own function.