Yii Framework Forum: getDbCriteria - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

getDbCriteria Call to a member function getDbCriteria() on a non-object Rate Topic: -----

#1 User is offline   durik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 16-December 10

Posted 17 January 2011 - 08:15 AM

i get

Call to a member function getDbCriteria() on a non-object

i've got write permission and the object is not empty, whats wrong ??????

code:

$model = new Project(); //name of my model Project refers to Mysql innoDB table tblproject.
$daten=$model::model()->with('projectdetails')->findAll();

$dataProvider = new CActiveDataProvider($daten);

$this->render('index',array(
'dataProvider'=>$dataProvider,
));
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 17 January 2011 - 08:49 AM

Check in your view, maybe you have a typo and you are not giving the correct dataprovider to the zii widget.
0

#3 User is offline   durik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 16-December 10

Posted 17 January 2011 - 08:59 AM

View Postzaccaria, on 17 January 2011 - 08:49 AM, said:

maybe you have a typo and you are not giving the correct dataprovider to the zii widget.


i don't know what a "typo" is ?
0

#4 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 17 January 2011 - 09:07 AM

Is a typing error. Is very probably that you simply wrote incorrectly somewhere a variable name, so you pass a null instead of the dataprovider.
0

#5 User is offline   durik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 16-December 10

Posted 17 January 2011 - 09:16 AM

View Postzaccaria, on 17 January 2011 - 09:07 AM, said:

Is a typing error. Is very probably that you simply wrote incorrectly somewhere a variable name, so you pass a null instead of the dataprovider.


first i thank for the quick answer :)

but im sure that i pass the correct variable name - u can see the code above
0

#6 User is offline   durik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 16-December 10

Posted 17 January 2011 - 09:28 AM

made a little progress, but didn't got far:

original my class is: myclass extends Controller;

guide says i've got to extend CActiveDataProvider.

And i can't find class Controller in the library.
0

#7 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 17 January 2011 - 10:17 AM

No, the class you are writing is a controller, so you have to extends CController.

The auto-generated code that you are using extends Controller, wich is a file in /protected/components wich extends CController.

The code you shared is correct, the point is if in the view index you are correctly passing the variable to the widget.
0

#8 User is offline   durik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 16-December 10

Posted 17 January 2011 - 10:19 AM

ok i obviously have to use the model (extends CActiveRecord) and pass it to the controller

So i created a method ( public function ) in the Model.

but now it says:

Fatal error: Call to a member function getDbCriteria() on a non-object in C:\xampp\yii\framework\web\CActiveDataProvider.php on line 114

it happens somewhere in the view, zaccaria was right with that,

but i don't
have any clue

what and where

in the view :(
0

#9 User is offline   durik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 16-December 10

Posted 17 January 2011 - 10:25 AM

@zaccaria
posted my last reply before i saw yours. im trying now to find the error in the view
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users