Nette JoinWhere, problem s pouzitim s vice JOINU

Aleksandr
Člen | 14
+
0
-

Zdravím chci poradit, k problemu:
TRACY:

No reference found for $article->uploaded_file.

takhle to nejde… s vice JOINama

public function getArticle($id) {
  $article = $this->getTable_Article()
      ->select('article.id AS article_id, article.appuser_id AS article_appuser_id, article.article_category_name AS article_article_category_name, '
          . 'article.business_id AS article_business_id, article.title AS article_title, article.content AS article_content,'
          . 'article.created AS article_created, article.published AS article_published, '
          . 'article_category.name AS article_category_name,article_category.title AS article_category_title,'
          . 'uploaded_file.path AS uploaded_file_path, uploaded_file.mimetype AS uploaded_file_mimetype')
      ->joinWhere('uploaded_file', 'uploaded_file.id = article.thumbnail_id')
      ->joinWhere('article_category', 'article.article_category_name=article_category.name')
      ->where('article.id', $id)
      ->fetch();
  return $article == false ? null : $article;
}

a takhle funguje

public function getArticle($id) {
  $article = $this->getTable_Article()
      ->select('article.id AS article_id, article.appuser_id AS article_appuser_id, article.article_category_name AS article_article_category_name, '
          . 'article.business_id AS article_business_id, article.title AS article_title, article.content AS article_content,'
          . 'article.created AS article_created, article.published AS article_published, '
          . 'article_category.name AS article_category_name,article_category.title AS article_category_title')
      ->joinWhere('article_category', 'article.article_category_name=article_category.name')
      ->where('article.id', $id)
      ->fetch();
  return $article == false ? null : $article;
}
tkn
Člen | 12
+
0
-

Máš v DB správně nastavené cizí klíče?

Aleksandr
Člen | 14
+
-1
-

tkn napsal(a):

Máš v DB správně nastavené cizí klíče?

Jak jako spravne ? ikdybych nemel vubec nastavene klice, tak by to melo reagovat jakmile spojuji podle urcitych hodnot ?

norbe
Backer | 405
+
0
-

JoinWhere funguje pouze jako doplněk k automatické podmínce. Není to tak, že výchozí podmínka kterou generuje nette se nepoužije…

Prostě nastav cizí klíč z thumbnail_id na uploaded_file. Pokud to z nějakého důvodu nemůžeš udělat, musíš si udělat vlastní implementaci IConventions