• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner confused with CI 2.0 Pagination

#1
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.
Reply

#2
You put your database queries inside your model.
Reply

#3
(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.
Reply

#4
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
Reply

#5
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
Reply

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

Thanks!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.