CodeIgniter Forums
Beginner confused with CI 2.0 Pagination - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Beginner confused with CI 2.0 Pagination (/showthread.php?tid=62149)



Beginner confused with CI 2.0 Pagination - jithinjohnygeorge - 06-13-2015

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.


RE: Beginner confused with CI 2.0 Pagination - solidcodes - 06-13-2015

You put your database queries inside your model.


RE: Beginner confused with CI 2.0 Pagination - Blair2004 - 06-14-2015

(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


RE: Beginner confused with CI 2.0 Pagination - RogerMore - 06-15-2015

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:
http://www.codeigniter.com/user_guide/overview/mvc.html

Hope this clarifies things.

-Roger


RE: Beginner confused with CI 2.0 Pagination - jithinjohnygeorge - 06-15-2015

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


RE: Beginner confused with CI 2.0 Pagination - kahumbu - 06-20-2015

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

Thanks!