Posted 28 October 2010 - 06:10 AM
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
1) 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?
Posted 28 October 2010 - 06:19 AM
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...
Posted 28 October 2010 - 06:49 AM
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
Posted 28 October 2010 - 06:56 AM
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...