I’m starting to use Yii.
Following a schema of DB , I have a table and from this table I want to retrive the values of only 2 fields present
- It is possible create a specific controller without to have a model?
2)In the controllers folder I just created a file named MyController with only 1 function as:
public function actionIndex()
$dataProvider=new CActiveDataProvider('index', array( 'criteria'=>array( $criteria->select=name,surname,age), ));
3)Under views I just created a folder reports and I created a index file with:
array('label'=>'Create Projects', 'url'=>array('create')),
array('label'=>'Manage Projects', 'url'=>array('admin')),
<?php $this->widget(‘zii.widgets.CListView’/‘zii.widgets.grid.CGridView’/, array(
I have error 404
Can I understand the right operation to do?
It is possible to create a controller without a model… but if you are working with data from the database… than the models are used just for that…
your code is wrong… because nowhere is specified what table to read data from ?
as you are getting a 404 error than maybe the URL you are trying is wrong…
Anyway as you are just starting with Yii I suggest you take a read at the Definitive Guide to Yii to get a better understanding how all this works…
thank you for the answer.
I’m following the useful guide but I’m appronching yii also to write code to understand at well the framework
about the table I changed:
$dataProvider=new CActiveDataProvider(‘Progetto’, array( ‘criteria’=>array( $criteria->select=name,surname,age), ));
but I continue to have error 404 and I don’t know what else
You really should first read the guide… and work with some examples… before trying to do something like this… it will be easyer and you would not post questions like this…
As per documentation - CActiveDataProvider provides data in terms of ActiveRecord objects which are of class modelClas, but you don’t have a model !
As I wrote before the 404 error can be even because you type a wrong URL…