SQL 上的条目被识别为列
The entry on SQL it's being recognized as column
我正在尝试使用扩展 RelatedContentByTags,但是 bolt_taxonomy 列上的 条目 被识别为 列.
当我将 {{ relatedcontentbytags(record) }}
放在 index.
上时出现此 错误
'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 );
}
}
根据您使用的数据库(我根据错误代码猜测是 Postgresql),用双引号 ""
括起来的文本可用于表示 table 名称;单引号 ''
通常用于表示字符文字,因此请尝试将 "published"
更改为 'published'
(entries、tags,当然还有 teste2)。
我正在尝试使用扩展 RelatedContentByTags,但是 bolt_taxonomy 列上的 条目 被识别为 列.
当我将 {{ relatedcontentbytags(record) }}
放在 index.
'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 );
}
}
根据您使用的数据库(我根据错误代码猜测是 Postgresql),用双引号 ""
括起来的文本可用于表示 table 名称;单引号 ''
通常用于表示字符文字,因此请尝试将 "published"
更改为 'published'
(entries、tags,当然还有 teste2)。