Ziskavani dat z 3 tabulek

Piticu
Člen | 93
+
0
-

Ahoj vsem,

mam nasledujici tabulky:

Project

id
template_id
user_id
......

Template

id
title
.....

Header

id
project_id
title
subtitle
.......

Potrebuji dostat do jednoho Selection sloupce Project.*,Header.*, Template.title. Podarilo se mi spojit Project a Header, ale nemuzu/nevim jak se dostat i k Template.title pomoci template_id.

Sloupce Project.* a Header.* ziskavam nasledovne:

$projects = $this->getDatabase()->table('project')
    ->select('project.*,template.title AS template_title')
    ->where('project.user_id',$this->getUser()->id)->fetchAll();

$data = $this->getDatabase()->table('header')
    ->select('project.*,header.*')
->where('header.project_id',$projects)->fetchAll();

Jak teda mohu dostat i Template.title do tohoto Selection.

Diky

EDIT: Problem vyresen. Pri iterace v sablone jsem pouzil ref :

	{foreach $user_projects as $key => $row}
		{$row->ref('template','template_id')->title}
{/foreach}

Editoval Piticu (1. 4. 2018 23:44)

Felix
Nette Core | 1247
+
0
-

Jen doplnim odkaz do dokumentace o Nette\Database, pro budouci generace.

https://doc.nette.org/…ase/explorer#…