The Model
We’ll start by creating a model in the application which needs to do two things: provide a count of all the records in the
Country
table, and retrieve a list of countries from the table. Save the following asmodels/countries.php
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| class Countries extends CI_Model { public function __construct() { parent::__construct(); } public function record_count() { return $this ->db->count_all( "Country" ); } public function fetch_countries( $limit , $start ) { $this ->db->limit( $limit , $start ); $query = $this ->db->get( "Country" ); if ( $query ->num_rows() > 0) { foreach ( $query ->result() as $row ) { $data [] = $row ; } return $data ; } return false; } }
|
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন