After hours of trying to figure out why my relations are not stored, I came across this very old thread:

Since I recently ran into a similar problem I found this thread. My setup is:

  • phalcon 1.3.1
  • apache 2.2.26
  • php 5.5.13
  • OS X Mavericks

Here's what I found experimenting with this. Lower case aliases ('artists', 'songs') don't seem to work whereas upper case aliases ('Artists', 'Songs') do.

To add one element this worked:

$this->Elements = $element;

To add multiple elements this worked:

$elements = array($element1, $element2);
$this->Elements = $elements;

After that I had to save the object before accessing the elements again. When I didn't, phalcon would just return a result set with only the elements already in the database.

Am I doing something seriously wrong or what?

This still (or again) seems to be the case in 3.4.0. Is this by design or a bug?