Récupérer données dans table de jointure
Bonjour à tous,
J'ai un petit problème: j'ai une table Catalogue qui est liée à la table JointuresGammes, elle-même lié à la table Gamme:
schema.yml
Code:
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| Catalogue:
connection: doctrine
tableName: catalogue
actAs:
Commentable:
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
designation:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
ref:
type: string(50)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
created_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
index_createur:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
JointuresGammes:
local: id
foreign: index_catalogue
type: many
JointuresGammes:
connection: doctrine
tableName: jointures_gammes
columns:
index_catalogue:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
index_gamme:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
Catalogue:
local: index_catalogue
foreign: id
type: one
Gammes:
local: index_gamme
foreign: id
type: one
Gammes:
connection: doctrine
tableName: gammes
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
intitule:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
description:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
JointuresGammes:
local: id
foreign: index_gamme
type: many |
J'ai fais un module avec un show basé sur le model Catalogue. Sauf que dans ce template j'aimerai afficher l'intitulé de la gamme lié à l'objet du catalogue.
Pour cela, j'ai essayé de faire les chose petit à petit en affichant d'abord l'Id de la gamme contenu dans la table JointuresGammes avant de passer au cran suivant.
Sauf que lorsque je fais:
Code:
<?php echo $catalogue->getJointuresGammes()->getIndexCatalogue() ?>
j'ai une erreur:
Citation:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Doctrine_Collection::getId' was given in ...\lib\vendor\symfony\lib\escaper\sfOutputEscaperObjectDecorator.class.php on line 64
J'ai regardé dans mon fichier BaseCatalogue.class.php et j'ai:
Code:
1 2
| <?php /* @method Doctrine_Collection getJointuresGammes() Returns the current record's "JointuresGammes" collection*/
?> |
A noter qu'en faisant
Code:
<?php echo $catalogue->JointuresGammes[0]->Gammes->getIntitule() ?>
, j'ai bien l'intitulé mais dans le cas où j'ai plusieur gammes, cela ne m'affichera qu'une seule gamme...
Je ne comprends pas ce qui ne va pas...
Merci de votre aide