How to use related() multiple times?

26 days ago

netteman
Member | 61
+
0
-

Hi

I know how to use

$this->database->table('book')->related(...)

https://doc.nette.org/…ase-explorer#… in this database https://ctrlv.cz/…/22/iBkw.png to get to the table book_tag and then to the table tag.

Is it possible to get even to tag_translation and keep the low number of queries generated by nette?

{foreach $books as $book}

    {$book->title}<br />

    {foreach $book->related('book_tag') as $book_tag}

        {$book_tag->tag->name}

        {foreach}
            code to echo translations of a tag
        {/foreach}

    {/foreach}

{/foreach}

11 days ago

stepos2
Backer | 1
+
+1
-
{foreach $books as $book}

    {$book->title}<br />

    {foreach $book->related('book_tag') as $book_tag}

        {$book_tag->tag->name}

        {foreach $book_tag->tag->related('tag_translation') as $tag_translation}

            {$tag_translation->translation}<br />

        {/foreach}

    {/foreach}

{/foreach}

4 days ago

netteman
Member | 61
+
0
-

Thank you!