I see CActiveDataProvider used in the controller actionIndex() function.
Is there any difference between using this instead of simply Post::model()->findAll()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CActiveDataProvideris a wrapper forCActiveRecordwith extended capabilities ofsorting,paginationandfiltering. TypicallyCActiveDataProvideris being used in conjunction withziiwidgets likeCListVieworCGridViewwhich are utilizing its sort and search capabilities. So if you want to display data in terms of list or table with (optional) sorting/filtering/pagination – most convenient way of doing it in Yii is using described zii widgets or their extensions.If you just need to fetch data and use it in any other way, but without smart rendering mechanisms provided by
CListVieworCGridView– useCActiveRecord, because it doesn’t perform anything else except of fetching of data.reference