I am trying to write an application using a mongo DB, and have hit a brick wall.

I have written some basic relationship handling functionality which uses the same syntax (run from initialize() ) as the model relationships but simply adds a named array of relationship information.

public function __call( $name, $args = [] ){

         * Add in the relationships.
        if( in_array( $name, [ 'hasOne', 'hasMany', 'belongsTo' ] ) ){

            $key = ( isset( $args[3]['alias'] ) ) ? $args[3]['alias'] : strtolower( $args[1] ) ;

            $this->_relationships[$key] = [
                'ref'      => $args[0],
                'model'    => $args[1],
                'modelRef' => $args[2],
                'options'  => $args[3],
                'type'     => $name



This is adding the raltionships correctly, (I am stepping through the code in X-DEBUG) but when I inspect the results from a call like this

$object = Object::findById( $object_id );

The initialization code has run, but the object does not have the relationships. The relationships ARE however in the object in


Does anyone have any idea what I am doing wrong, or is it a bug in phalcon?