Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony]sfWidgetFormPropelChoice i multiple
trucksweb
post
Post #1





Grupa: Zarejestrowani
Postów: 1 199
Pomógł: 31
Dołączył: 22.03.2004
Skąd: Warszawa

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


mam problem z taka tabela w symfony:

wiaze uzytkownika z innymi uzytkownikami i mam taka tabele:

catalog_user_account:
id_warder:
type: INTEGER
required: true
primaryKey: true
foreignTable: catalog_user_account
foreignReference: id_user_account
onDelete: CASCADE
onUpdate: CASCADE
id_user_account:
type: INTEGER
required: true
primaryKey: true
foreignTable: catalog_user_account
foreignReference: id_user_account
onDelete: CASCADE
onUpdate: CASCADE



forma wyglada tak:
  1. $c = new Criteria();
  2. $c->addMultipleJoin(array(array(CatalogUserAccountPeer::ID_USER_GROUP, CatalogUserGroupPeer::ID_USER_GROUP),
  3. array(CatalogUserGroupPeer::CODE_NAME, '"user"')));
  4.  
  5.  
  6. $this->setWidgets(array(
  7. 'id_warder' => new sfWidgetFormChoice(array('choices' => CatalogLedScreenUserAccount::getWardersArray())),
  8. 'id_user_account' => new sfWidgetFormPropelChoice(array('model' => 'CatalogUserAccount', 'criteria' => $c, 'multiple'=>true))
  9. ));
  10.  
  11. $this->setValidators(array(
  12. 'id_warder' => new sfValidatorPropelChoice(array('model' => 'CatalogUserAccount', 'column' => 'id_user_account', 'required' => false)),
  13. 'id_user_account' => new sfValidatorPropelChoice(array('model' => 'CatalogUserAccount', 'multiple' => true)),
  14. ));


i teraz przesylajac dane:
  1. $array['id_warder'] = 1
  2. $array['id_user_account'] = array(0 => 2, 1 => 3);


i zapisuje mi tylko id_warder, i 1 jako id_user_account

chce zeby utworzylo mi dwa wpisy w bazie przy jednym zapisie:
id_warder, id_user_account
1, 2
1, 3

dlaczego ?


//edit
odpowiem sobie sam ze to raczej nie jest wykonalne, byc moze cos sknocilem w bazie ale rozwiazalem to w inny sposob:

stworzylem sobie tabele tylko i wylacznie z id_warder jako kluczem glownym

potem spec_warder_user:
id_warder (relacja do tej tabeli wylacznie z id_warder)
id_user (relacja do users)

i teraz wszystko pieknie smiga (IMG:style_emoticons/default/smile.gif)

Ten post edytował trucksweb 14.04.2011, 13:41:03
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
jaro87
post
Post #2





Grupa: Zarejestrowani
Postów: 53
Pomógł: 7
Dołączył: 10.03.2011
Skąd: Wrocław

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


W 1.4 taka schema nawet nie pozwala na przebudowanie modelu:

Kod
1:1 relationship expressed by foreign key catalog_user_account_FK_2 is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.


Której konkretnie wersji Symfony używasz?
Go to the top of the page
+Quote Post

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: 23.08.2025 - 00:30