tags:

views:

28

answers:

1

Hi, I'm generating my models from database and I get something like this:

public function setUp()
{
    parent::setUp();
    $this->hasOne('Articles', array(
         'local' => 'article_id',
         'foreign' => 'id'));

    $this->hasOne('Users', array(
         'local' => 'voter_id',
         'foreign' => 'id'));

    $this->hasOne('Users as Users_4', array(
         'local' => 'author_id',
         'foreign' => 'id'));
}

Is there any way to tell doctrine, what should be the names of relationships. For example to get something like this:

public function setUp()
{
    $this->hasOne('Articles', array(
         'local' => 'article_id',
         'foreign' => 'id'));

    $this->hasOne('Users as Voter', array(
         'local' => 'voter_id',
         'foreign' => 'id'));

    $this->hasOne('Users as Author', array(
         'local' => 'author_id',
         'foreign' => 'id'));
}

I know it is possible when you generate models from YAML files or write them from scratch, but is it possible when you generate models from DB?

A: 

There's no way to do what you are asking. As an alternative, you could generate a YAML file from the db, add the relation names there, and then generate your models from the YAML file.

BenV