I'm trying to improve this Controller method written in Yii2 (PHP). It passes data to a paginator, but not all data that is available in the database is included. When I sort a column from A to Z, I see the beginning; when I sort from Z to A, I see the end of the data, but only on up to two pages, never all the data. I would like to print out either the SQL statement running in the background or output the retrieved model objects to see what's being passed to the view. However, I haven't been able to produce an output that displays the SQL query or the content of the retrieved objects.
I can see that either $model or the $dataProviderSearched variable could provide this data, but I'm unsure how to extract it.
<?php
class ProjectsController extends Controller
{
/*
* ACTIONS
*/
public function actionIndex()
{
$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl . '/js/rights.js');
$cs->registerCssFile($baseUrl . '/css/rights.css');
Booster::getBooster()->registerPackage('select2');
$model = new Projects('search');
$model->unsetAttributes();
if (isset($_GET['Projects']))
$model->attributes = $_GET['Projects'];
if ($this->hasRole('ViewAllProject', true)) $dataProviderSearched = $model->search();
else
$dataProviderSearched = $model->search(Yii::app()->getModule("admin")->getComponent("RoleManager")->getViewableIds("project"));
$this->pageTitle = Yii::t('app_translator', 'Projektjeim');
$this->render('index', array(
'dataProvider' => $model,
'dataProviderSearched' => $dataProviderSearched,
));
}