Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [CakePHP] relacje
kicaj
post
Post #1





Grupa: Zarejestrowani
Postów: 1 640
Pomógł: 28
Dołączył: 13.02.2003
Skąd: Międzyrzecz/Poznań

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


Probuje stworzyc relacje w ten sposob:
Kod
Article hasOne User
User hasMany Article
User hasMany Comments
Articles hasMany Comments


Tabela 'comments' chcialbym zeby wygladala mniej wiecej tak:
Kod
id
content
user_id
model
foreign_key
...


Przykladowe wiersze w tabeli 'comments':
Kod
1, 'Witaj kolego!' 123, User, 3        // user_id=123 dodal komentarz do uzytkownika o id=3
2, 'Dobry artykul!', 234, Article, 42    // user_id=234 dodal komentarz do artykulu o id=42


Czy to jest dobry sposob dla tabeli 'comments', dobre rozumowanie.
I w jaki sposob mialby dzialac model Comment?

Ten post edytował kicaj 10.01.2009, 02:30:52
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kicaj
post
Post #2





Grupa: Zarejestrowani
Postów: 1 640
Pomógł: 28
Dołączył: 13.02.2003
Skąd: Międzyrzecz/Poznań

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


Czy automatycznie powinno pojawic sie pole 'Comment.model' w $this->data?
Bo sie nie pojawia...

A recznie $this->data['Comment']['model'] = 'Article' mija sie chyba z celem?

Ten post edytował kicaj 12.01.2009, 01:38:09
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: 15.10.2025 - 03:55