Cristhian Boujon Tue Oct 23 14:55:51 -0400 2012

Subject: $has_many does not work

0 down vote favorite

I'm developing a web app(PHP) with an already database(MySQL) existing. I'm using ActiveRecord ORM and I have some issue with one-to-many relationship.

Models: (orden.php) (dato_orden.php) (Tables)

Basically one "orden" has many "datosorden" and one "datoorden" belongs to one "orden". When I try:

var_dump(Orden::find(1)->datos_ordenes); // NULL <- Does not work.
var_dump(DatoOrden::find(1)->orden1->idorden); // string(1) "1" <- Works!

Why $has_many does not works but $belongs_to does it?