Código PHP:
$game1->setWinnerAs('home');
$game2->setWinnerAs('visitor');
$game3 =& Game::factory($id);
$game3->setWinnerAs('home');
Así queda finalmente la BD:
Código PHP:
select * from cup
+----+----------+--------+
| id | name | winner |
+----+----------+--------+
| 1 | TEST Cup | 1 |
+----+----------+--------+
select * from game
+----+--------+---------------------+-----------+------------+--------+--------+
| id | cup_id | play_date | team_home | team_visit | winner | result |
+----+--------+---------------------+-----------+------------+--------+--------+
| 1 | 1 | 2008-03-20 00:00:00 | 1 | 2 | 1 | NULL |
| 2 | 1 | 2008-03-20 00:00:00 | 3 | 4 | 4 | NULL |
| 3 | 1 | 2008-03-21 00:00:00 | 1 | 4 | 1 | NULL |
+----+--------+---------------------+-----------+------------+--------+--------+
Y este es el output del programa:
The home team won game 1!!
---------------------------------------------------------------------------------
Notifying of event WinnerOfGame by Game@id=1
Game id: 3 is being notified of a winner.
It's the result of game: 1 and it's team 1
Params :
Array
(
[setas] => home
)
Now the home team of game 3 is 1
---------------------------------------------------------------------------------
Notifying of event LooserOfGame by Game@id=1
Who cares... :P
---------------------------------------------------------------------------------
The visitor team won game 2!!
---------------------------------------------------------------------------------
Notifying of event WinnerOfGame by Game@id=2
Game id: 3 is being notified of a winner.
It's the result of game: 2 and it's team 4
Params :
Array
(
[setas] => visitor
)
Now the visitor team of game 3 is 4
---------------------------------------------------------------------------------
Notifying of event LooserOfGame by Game@id=2
Who cares... :P
---------------------------------------------------------------------------------
The home team won game 3
---------------------------------------------------------------------------------
!!Notifying of event WinnerOfGame by Game@id=3
Cup id: 1 is being notified of a winner.
It's the result of game: 3 and it's team 1
Params :
Array
(
[0] =>
)
Congratulations team 1. Yuo Won the TEST Cup
---------------------------------------------------------------------------------
Notifying of event LooserOfGame by Game@id=3
Who cares... :P