bonjour,
j'aimerait savoir comment gérer une requette doctrine avec symfony (géré clé étrangére) par exemple traduire cette requette vers doctrine:
select * from clientt,fac where clientt.idclientt=fac.idclient
1 2 3 4 5
| clientt (idclient,...)
fac (idclient,num_fac,...)
ALTER TABLE `fac`
ADD CONSTRAINT `fac_ibfk_1` FOREIGN KEY (`idclient`) REFERENCES `clientt` (`idclientt`); |
1 2 3 4 5 6 7 8 9 10 11
| lib/model/doctrine/ClienttTable.class :
public function column(){
$q = Doctrine_Query::create()
->select('c.*,f.*')
->from('clientt c, fac f')
->where('c.idclientt=f.idclient);
return $q->execute();
} |
1 2 3
| actions.class.php :
$this->clientts = Doctrine::getTable('Clientt')->column(); //appel a fonction |
1 2 3 4 5 6 7 8 9 10
| indexSuccess.php :
<?php foreach ($clientts as $clientt): ?>
<tr>
<td><?php echo $clientt->getFac()->getIdclient() ?></td> //recupérer champ de la table fac
<td><?php echo $clientt->getDatee() ?></td> //recupérer champ de la table client
<?php endforeach; ?> |
Partager