これは私のモデルです
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 を設定すると結果が得られないのはなぜですか?