这是我的模型
function get_one_news($limit = 2, $offset = null) {
if ($limit) {
$this->db->limit($limit, $offset);
}
$this->db->order_by('news.added_on', 'desc');
return $this->db->get('news');
}
在我的控制器中我已经分配了它
$data['news'] = $this->news_model->get_one_news();
在我看来,我已经实现了它
<div class="col-md-8 col-lg-8">
<!-- artigo em destaque -->
<?php if ($news->num_rows()):?>
<?php foreach ($news->result() as $n):?>
<?php if ($n->cat_id == 17):?>
<div class="featured-article">
<a href="#">
<?php if ($n->image != ''): ?>
<img src="<?php echo base_url('uploads/'.$n->image);?>" alt="" class="thumb">
<?php endif;?>
</a>
<div class="block-title">
<h4><?php echo $n->title = word_limiter($n->title, 7);?></h4>
</div>
</div>
<!-- /.featured-article -->
<?php endif;?>
<?php endforeach;?>
<?php endif;?>
</div>
这个查询给了我结果,但是如果我输入限制 3,它给 2,如果我输入 2,它给 1,如果我输入 1,它不会给出任何结果,为什么?