这是我想做的,但似乎不可能:(编辑:将单引号更改为双引号)
function get_archives($limit, $offset) { $query = $this->db->query(" SELECT archivalie.id, archivalie.signature, type_of_source.description AS type_of_source_description, media_type.description AS media_type_description, origin.description AS origin_description
FROM archivalie,
type_of_source,
media_type,
origin
WHERE archivalie.type_of_source_id = type_of_source.id
AND type_of_source.media_type_id = media_type.id
AND archivalie.origin_id = origin.id
ORDER BY archivalie.id ASC
LIMIT $limit, $offset
");
// etc...
} 它给出此错误:(编辑:使用双引号并在URL中传递了偏移号的新错误消息)
ERROR: LIMIT #,# syntax is not supported HINT: Use separate LIMIT and OFFSET clauses. 仅当您使用ActiveRecord格式传递变量时,它才有效:
$this->db->select('archivalie.id, archivalie.signature, etc, etc'); // from, where, etc. $this->db->limit($limit, $offset);
$query = $this->db->get();
问题来源于stack overflow
$query = $this->db->query(' SELECT archivalie.id, archivalie.signature, type_of_source.description AS type_of_source_description, media_type.description AS media_type_description, origin.description AS origin_description FROM archivalie, type_of_source, media_type, origin WHERE archivalie.type_of_source_id = type_of_source.id
AND type_of_source.media_type_id = media_type.id
AND archivalie.origin_id = origin.id
ORDER BY archivalie.id ASC LIMIT ? OFFSET ?',array($limit,$offset));
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。