![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 16 Pomógł: 3 Dołączył: 8.12.2008 Ostrzeżenie: (0%) ![]() ![]() |
Czesc, mam sobie baze danych, schema.yml:
propel: category: _attributes: { phpName: Category } id: { type: integer, required: true, primaryKey: true, autoincrement: true } name: varchar(255) product: _attributes: { phpName: Product, isI18n: true, i18nTable: product_i18n } id: { type: integer, required: true, primaryKey: true, autoincrement: true } category_id: { type: integer, foreignTable: category, foreignReference: id, required: true, onDelete: CASCADE } img1: varchar(255) img2: varchar(255) img3: varchar(255) czyli wiadomo kategoria (1 - n) produkt generalnie chce wyswietlic w templacie taka strukture: <ul class="level1" id="root"> <?php foreach($kategorie as $kategoria): ?> <li><a href="#"><?php echo $kategoria->getName()?></a> <ul class="level2"> <?php foreach($kategoria->getProducts() as $product): ?> <li><a href="" ><?php echo $product->getName()</a></li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul> </div> Wiadomo ze ta konstrukcja nie jest optymalna bo dla kazdego obiektu $kategoria zostanie wykonane zapytanie sql zwracajace liste produktow i teraz moje pytanie: jak zrobic to jednym zapytanie, czyli wiadomo trzeba zlaczyc join tabele tylko wtedy bede mial problem z wyswietleniem tego w templacie. Bardzo bym prosil o jakas porade jak to wyswietlic :] wszelkie sugestie mile widziane. |
|
|
![]() ![]() |
![]() |
Aktualny czas: 24.08.2025 - 04:22 |