Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Symfony 1.4 - pobieranie danych
damianooo
post
Post #1





Grupa: Zarejestrowani
Postów: 496
Pomógł: 2
Dołączył: 15.07.2011
Skąd: Katowice

Ostrzeżenie: (0%)
-----


Witam,


Mam następujący schemat bazy z dwiema tabelami:

  1. Team:
  2. actAs:
  3. Timestampable: ~
  4. columns:
  5. name:
  6. type: varchar(100)
  7. notnull: true
  8.  
  9. Meet:
  10. actAs:
  11. Timestampable: ~
  12. columns:
  13. team1_id:
  14. type: integer
  15. notnull: true
  16. team2_id:
  17. type: integer
  18. notnull: true
  19. relations:
  20. Team1:
  21. class: Team
  22. local: team1_id
  23. foreign: id
  24. Team2:
  25. class: Team
  26. local: team2_id
  27. foreign: id






Jak widać Tabela MEET zawiera dwa pola z ID pochodzące z tabeli TEAM. Dzięki temu MEET (SPOTKANIE) to połącznie dwóch TEAM (DRUŻYN).

I teraz tak:

w Kontrolerze action.class.php w metodzie executeIndex() mam tak:

  1. $this->meets = MeetTable::getInstance()->findAll();


Natomiast w Widoku indexSuccess.php mam tak:

  1. <?php foreach ($meets as $meet):?>
  2. <?php echo $meet->getTeam1Id() . ' - ' . $meet->getTeam2Id()?>
  3. <br />
  4. <?php endforeach;?>




Nie wiem jednak jak wyświetlić nazwy drużyn zamiast ID

proszę o podpowiedź,

dzięki




Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
szalek01
post
Post #2





Grupa: Zarejestrowani
Postów: 129
Pomógł: 17
Dołączył: 17.09.2012

Ostrzeżenie: (0%)
-----


  1. <?php echo $meet->getTeam1(); ?>

w basach masz i tu znajdziesz metody które możesz wywołać na obiekcie Meet

/**
* BaseMeet
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $team1_id
* @property integer $team2_id
* @property Team $Team1
* @property Team $Team2
*
* @method integer getTeam1Id() Returns the current record's "team1_id" value
* @method integer getTeam2Id() Returns the current record's "team2_id" value
* @method Team getTeam1() Returns the current record's "Team1" value
* @method Team getTeam2() Returns the current record's "Team2" value
* @method Meet setTeam1Id() Sets the current record's "team1_id" value
* @method Meet setTeam2Id() Sets the current record's "team2_id" value
* @method Meet setTeam1() Sets the current record's "Team1" value
* @method Meet setTeam2() Sets the current record's "Team2" value
*
* @package test
* @subpackage model
* @author Your name here
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseMeet extends sfDoctrineRecord

Ten post edytował szalek01 13.10.2012, 19:40:43
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 14:31