$this->db->offset() 有这个?
偶然在STBlog中看到这行,比如:/**
* 获取内容列表
*
* @access public
* @param string$type 内容类型
* @param string$status 内容状态
* @param int $author_id 作者ID (optional)
* @param int $limit 条数 (optional)
* @param int $offset 偏移量 (optional)
* @param int $category_filter 需要过滤的栏目ID (optional)
* @param int $title_filter 需要过滤的标题关键字 (optional)
* @param bool $feed_filter 是否显示在feed里面 (optional)
* @return array内容列表信息
*/
public function get_posts($type = 'post', $status = 'publish', $author_id = NULL, $limit = NULL, $offset = NULL, $category_filter = 0, $title_filter = '', $feed_filter = FALSE)
{
$this->db->select('posts.*, users.screenName');
$this->db->join('users','users.uid = posts.authorId');
//type
if($type && in_array($type, $this->_post_type))
{
$this->db->where('posts.type', $type);
}
//status
if($status && in_array($status,$this->_post_status))
{
$this->db->where('posts.status', $status);
}
//author
if(!empty($author_id))
{
$this->db->where('posts.authorId', intval($author_id));
}
//category filter
if(!empty($category_filter))
{
$this->db->join('relationships','posts.pid = relationships.pid','left');
$this->db->where('relationships.mid', intval($category_filter));
}
//title filter
if(!empty($title_filter))
{
$this->db->like('posts.title', $title_filter);
}
//feed filter
if($feed_filter)
{
$this->db->where('allowFeed', 1);
}
$this->db->order_by('posts.created','DESC');
//limit
if($limit && is_numeric($limit))
{
$this->db->limit(intval($limit));
}
//offset
if($offset && is_numeric($offset))
{
$this->db->offset(intval($offset));
}
return $this->db->get(self::TBL_POSTS);
}
怎么手册里没有 $this->db->offset() ?
Software API可分为两类,documented与undocumented。
Documented API是官方发布,属权威性,极少会改变。即使要改,一般会保留backward compatibility。因其它开发者倚靠官方发布的API进行开发,任何API改动皆会对大量原有软件产生影响,修改补救的工作量可不是开玩笑的。真的必须要改变时会有大量工作配合以减低影响。
Undocumented API是存在可用的,但官方未曾发布,使用的话,各安天命,将来变了而出错,怪不得人。官方并无任何责任!
一般非不得意才会使用Undocumented API。
$this->db->offset();可在database/DB_active_rec.php内找到,属Active Record的undocumented API。 燃雲 发表于 2011-7-22 08:49 static/image/common/back.gif
Software API可分为两类,documented与undocumented。
Documented API是官方发布,属权威性,极少会改变。 ...
懂了
谢谢
页:
[1]