这是我想做的,但似乎不可能:(编辑:将单引号更改为双引号)
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();