2015-06-30 64 views
0

我試圖使用擴展RelatedContentByTags,但bolt_taxonomy列進入它被認定爲在SQL它條目的被認可爲

我有這個錯誤當我把{{ relatedcontentbytags(record) }}索引。

'Twig_Error_Runtime thrown with message 
"An exception has been thrown during the rendering of a template 
("An exception occurred while executing ' SELECT bolt_entries.id FROM bolt_entries LEFT JOIN 
bolt_taxonomy ON bolt_entries.id = bolt_taxonomy.content_id WHERE 
bolt_entries.status = "published"AND bolt_entries.id != 3 AND 
bolt_taxonomy.contenttype = "entries" AND (bolt_taxonomy.taxonomytype = "tags" AND 
(bolt_taxonomy.slug = "teste2"))': 

SQLSTATE[42703]: Undefined column: 7 ERROR: column "published" does not exist 
LINE 1: ...t_taxonomy.content_id WHERE bolt_entries.status = "published...^") in "entry.twig" at line 65." 

而且extension.php是:根據您所使用的數據庫

$results = array(); 
     foreach ($tables as $name) { 

      $table  = sprintf('%s%s', $tablePrefix, $name); 
      $querySelect = ''; 
      $querySelect .= sprintf(' SELECT %s.id FROM %s', $table, $table); 
      $querySelect .= sprintf(' LEFT JOIN %s', $taxonomyTable); 
      $querySelect .= sprintf(' ON %s.id = %s.content_id', $table, $taxonomyTable); 
      $querySelect .= sprintf(' WHERE %s.status = "published"', $table); 
      if ($name == $record->contenttype['slug']) { 
       $querySelect .= sprintf('AND %s.id != '. $record->id, $table); 
      } 
      $querySelect .= sprintf(' AND %s.contenttype = "%s"', $taxonomyTable, $name); 
      $querySelect .= sprintf(' AND (%s)', $queryWhere); 

      $queryResults = $app['db']->fetchAll($querySelect); 

      if (!empty($queryResults)) { 
       $ids  = implode(' || ', \utilphp\util::array_pluck($queryResults, 'id')); 
       $contents = $app['storage']->getContent($name, array('id' => $ids, 'returnsingle' => false)); 
       $results = array_merge($results, $contents); 
      } 
     } 
+0

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS –

回答

1

(我根據錯誤代碼猜測PostgreSQL的)文本用雙引號""可以用來表示表名;單引號''通常用來表示字符文字,所以嘗試改變"published"'published'(這同樣適用標籤teste2過的課程)。

+1

謝謝!這解決了。 –

相關問題