Ver Mensaje Individual
  #10 (permalink)  
Antiguo 21/03/2008, 14:28
Avatar de pragone
pragone
 
Fecha de Ingreso: diciembre-2007
Ubicación: Madrid
Mensajes: 223
Antigüedad: 16 años, 5 meses
Puntos: 2
Re: Opiniones sobre el patrón de Invocación Implicita

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 |
+----+----------+--------+
|  
TEST Cup |      |
+----+----------+--------+

select from game
+----+--------+---------------------+-----------+------------+--------+--------+
id cup_id play_date           team_home team_visit winner result |
+----+--------+---------------------+-----------+------------+--------+--------+
|  
|      2008-03-20 00:00:00 |         |          |      NULL   |
|  
|      2008-03-20 00:00:00 |         |          |      NULL   |
|  
|      2008-03-21 00:00:00 |         |          |      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
__________________
pragone
Blog: Desarrollo, comunidad y monetización
Últimos artículos: Tips de Smarty