Hey All :) I've been doing a new project with MySQL instead of MongoDB since I need more relational capabilities.
I've seen the easy way Phalcon allows to configure relations and tried to add it.
There are two defined models:
Customers - Have an "id"
Checkins - Have an "id" and "customer" (which is the same as customer ID)
I'm connecting both with
// This is in "initialize()" in Customers.php Model $this->hasMany("id", "Checkins", "customer"); // This is in "initialize()" in Checkins.php Model $this->belongsTo("customer", "Customers", "id");
This seems pretty straightforward but when I fetch a customer and try to get his checkins I'm getting an empty object:
$c = Customers::findFirst(); $this->response->setJsonContent($c->checkins); // Returns empty object return $this->response;
Needless to say, the "checkins" table has a checkin with a 'customer' field corresponding to an existing customer in the "customers" table.
Am I missing any steps? Maybe some special indexing is required?
Many thanks, Shai.