Skip to content

[NFR] Multiple Modules Models Alias and leftJoin #1111

Description

@ovr

Hi all,
I have model

class Event
  extends Model
{
  public $id;
  public $created_at;
  public $user_id;
  public $type_id;
  public $product_id;

  public function initialize()
  {
    $this->hasOne('product_id', 'Product\\Model\Product', 'id', array(
       'foreignKey' => true,
       'alias' => 'Product'
    ));
    $this->hasOne('user_id', 'User\\Model\User', 'id', array(
      'foreignKey' => true,
      'alias' => 'User'
    ));
    $this->hasOne('type_id', 'User\\Model\Events\Type', 'id', array(
      'foreignKey' => true,
      'alias' => 'Type'
    ));
    $this->hasMany('user_id', 'User\\Model\Follow\User', 'author_user_id', array(
      'foreignKey' => true,
      'alias' => 'Followers'
    ));
  }

  /**
   * Independent Column Mapping.
   */
  public function columnMap() {
    return array(
      'id' => 'id',
      'created_at' => 'created_at',
      'user_id' => 'user_id',
      'type_id' => 'type_id',
      'product_id' => 'product_id'
    );
  }
}

I would like to use

        $builder = $this->modelsManager->createBuilder('e')
            ->addFrom('User\Model\Event', 'e')

            ->leftJoin('e.User', null, 'u')

On Forum http://forum.phalconphp.com/discussion/766/multiple-relations-and-left-joind-models

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleStale issue - automatically closed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions