bonjours j'ai deux tables mysql reliées par une foreign_key, j'ai générer mes modèles avec doctrine:
Artists.php:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
<?php
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('App_Models_Artists', 'doctrine');
 
/**
 * App_Models_Base_Artists
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @property integer $id_artist
 * @property string $nom
 * @property string $id_facebook
 * @property string $bio
 * @property integer $ordre
 * @property Doctrine_Collection $ArtistsHaveLinks
 * 
 * @package    ##PACKAGE##
 * @subpackage ##SUBPACKAGE##
 * @author     ##NAME## <##EMAIL##>
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 */
abstract class App_Models_Base_Artists extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('artists');
        $this->hasColumn('id_artist', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => true,
             'autoincrement' => true,
             ));
        $this->hasColumn('nom', 'string', 20, array(
             'type' => 'string',
             'length' => 20,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('id_facebook', 'string', 30, array(
             'type' => 'string',
             'length' => 30,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('bio', 'string', 5000, array(
             'type' => 'string',
             'length' => 5000,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('ordre', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
    }
 
    public function setUp()
    {
        parent::setUp();
        $this->hasMany('App_Models_ArtistsHaveLinks as ArtistsHaveLinks', array(
             'local' => 'id_artist',
             'foreign' => 'id_artist'));
    }
}
et ArtistsHaveLinks.php:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
<?php
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('App_Models_ArtistsHaveLinks', 'doctrine');
 
/**
 * App_Models_Base_ArtistsHaveLinks
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @property integer $id_link
 * @property integer $id_artist
 * @property string $img_link_artist
 * @property string $url_link_artist
 * @property integer $ordre
 * @property App_Models_Artists $Artists
 * 
 * @package    ##PACKAGE##
 * @subpackage ##SUBPACKAGE##
 * @author     ##NAME## <##EMAIL##>
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 */
abstract class App_Models_Base_ArtistsHaveLinks extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('artists_have_links');
        $this->hasColumn('id_link', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => true,
             'autoincrement' => true,
             ));
        $this->hasColumn('id_artist', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('img_link_artist', 'string', 50, array(
             'type' => 'string',
             'length' => 50,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('url_link_artist', 'string', 100, array(
             'type' => 'string',
             'length' => 100,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('ordre', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
    }
 
    public function setUp()
    {
        parent::setUp();
        $this->hasOne('App_Models_Artists as Artists', array(
             'local' => 'id_artist',
             'foreign' => 'id_artist'));
    }
}
ma classe artist a bien une Doctrine_Collection $ArtistsHaveLinks

je comprend pas comment faire pour la peupler,
se peuple elle automatiquement lors d'un select * sur la table artists dans ce cas comment accéder a la collection

je souhaiterais récupérer un objet avec un vecteur pour les liens mais je c pas comment faire.
Merci d'avance.