Welcome Guest, Not a member yet? Register   Sign In
Beginner confused with CI 2.0 Pagination

I am new to CI and I have only limited knowledge in programming. I am working on a small project developing in CI 3.0.

I need to fetch some data(rows) from database and show the result using pagination.

I went through the documentation and confused with where the database query to be executed / where the model to be called.

I expect some help. Thanks in Advance.

You put your database queries inside your model.

(06-13-2015, 03:33 PM)solidcodes Wrote: You put your database queries inside your model.

He's right it's should be called "best pratices" since extending ci_model your class herits  of db object
NexoPOS 2.6.2 available on CodeCanyon.

(This post was last modified: 06-15-2015, 01:19 AM by RogerMore.)

CodeIgniter is based on the MVC (Model-View-Controller) development pattern. This pattern dictates that data, html and logic should be separated, but with CI it is possible to derive from the pattern. You can put database queries in a view if you really want, but it's certainly not the best way of doing things.
So here it goes...
Models are classes with methods to retrieve, insert and change your data.
A view is a (part of a) webpage.
The controller hold most of the logic, where you call a method of the model to retrieve your data, which you can give to a view to display it on a webpage.

There is a section in the documentation about this which you can find at:

Hope this clarifies things.


I was confused with how the query result can be made associated with Pagination. Now I fixed it.

RogerMore , Blair2004, Offline solidcodes thanks for your help

Can you share how you did it and, if possible, your code?


Theme © iAndrew 2016 - Forum software by © MyBB