[英]Drupal 7 theme('pager') -> PDOException: SQLSTATE[42S02]: Base table or view not found
我第一次在论坛上寻求帮助已经很长时间了。 通常,通过查看其他帖子可以找到我需要的东西。。。我真的很困惑,所以需要帮助。
我试图在Drupal 7中使用theme('pager')
对我从db_select
查询中获得的表结果进行分页。
当我包含该行时,以下查询会产生错误:
$output .= theme('pager');
如果我不填写这一行,我将从表中获得预期的有限5个结果。
我的代码:
// Set external databse
db_set_active('nondrupal');
// build query to get desired results
$query = db_select('diary', 'n')
->fields('n', array('photo_id', 'photo'))
->orderBy('photo_id', 'DESC');
//Create a new object from extend. The reason for this is that extend() creates a new object which wraps the current object (Decorator pattern).
$query = $query->extend('PagerDefault')->limit(5);
// Execute query and add to array
$result = $query->execute();
// empty output var
$output = NULL;
// Loop through results and output each row for chosen columns
foreach($result as $row) {
$output .= $row->photo_id.': '.$row->photo.'<br />';
}
// Show pagination in output
$output .= theme('pager');
// echo output to screen
echo $output;
// Set db connection back to default (drupal)
db_set_active();
没有theme('pager')
行,页面呈现良好。
有了它我得到一个错误:
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table
'dbMYDATABASENAME.semaphore' doesn't exist: SELECT expire,
value FROM {semaphore} WHERE name = :name; Array ( [:name] =>
theme_registry:runtime:garland:cache ) in lock_may_be_available() (line 167
of /homepages/28/d228752694/htdocs/drupal7/includes/lock.inc).
找不到基表或视图似乎是关键,但是我看不到为什么包括主题功能会导致此错误。 我有一个基本的Drupal 7安装。
感谢您的帮助!
Madmilner
错误归结为:
// Show pagination in output
$output .= theme('pager');
// echo output to screen
echo $output;
高于db_set_active();
不知道为什么会这样,但是可以解决问题。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.