我有这个代码:
public function index($offset = 0) {
$params = array(
'stream' => 'companies',
'namespace' => 'companies',
'paginate' => 'yes',
'pag_segment' => 3
);
// Build regular expression to match items from DB
$regexp = "'^[" . strtolower($this->uri->segment(4)) . strtoupper($this->uri->segment(4)) . "]'";
$params['where'] = "name REGEXP " . $regexp;
$entries = $this->streams->entries->get_entries($params);
$this->template->set('items', $entries)->build('index');
}
我不知道为什么,但我收到了两个查询,请参阅下面的详细信息:
0.0008 SELECT default_companies.*, cb_users.id as created_by||user_id, cb_users.email as created_by||email, cb_users.username as created_by||username,profiles.display_name as created_by||display_name FROM default_companies LEFT JOIN default_users as cb_users ON cb_users .id=default_companies.created_by LEFT JOIN default_profiles 作为配置文件 ON profiles.user_id=default_companies.created_by WHERE (name REGEXP '^[mM]') ORDER BY
default_companies
。created
DESC
这个查询是正确的,它会生成有效的记录,但是......
0.0008 SELECT default_companies.*, cb_users.id as created_by||user_id, cb_users.email as created_by||email, cb_users.username as created_by||username,profiles.display_name as created_by||display_name FROM default_companies LEFT JOIN default_users as cb_users ON cb_users .id=default_companies.created_by LEFT JOIN default_profiles 作为配置文件 ON profiles.user_id=default_companies.created_by WHERE (name REGEXP '^[mM]') ORDER BY
default_companies
。created
DESC 限制 10 偏移量 4
第二个查询(还不知道为什么执行它)不返回任何值,因为OFFSET
参数所以我的视图总是空的。这里有什么问题?我错过了什么?我正在运行 PyroCMS 2.2.1 社区