Yii Framework Forum: What Is The In Put Of Cactivedataprovider - Yii Framework Forum

Jump to content

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

What Is The In Put Of Cactivedataprovider Rate Topic: -----

#1 User is offline   Pan_mamkkl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-September 12

Posted 01 July 2013 - 09:00 AM

I have viewed the documentation and found such description of $modelClass: "the model class (e.g. 'Post') or the model finder instance (e.g. Post::model(), Post::model()->published())."

However, when I input my "OrderDetails" models it outputs an error message:" Fatal error: Call to a member function getDbCriteria() on a non-object"

Here is my code

public function actionViewDetail($o_id){
		$order = Order::model()->findByPk($o_id);
		$dataProviderSet=new CActiveDataProvider($order->orderDetails);
		$this->render('indexDetail',array(
			'dataProviderSet'=>$dataProviderSet,
		));
}


orderDetails already defined in Order Class's relations.

public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idMember' => array(self::BELONGS_TO, 'Member', 'id_member'),
			'orderDetails' => array(self::HAS_MANY, 'OrderDetails', 'id_order'),
		);
	}

0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,600
  • Joined: 04-March 10
  • Location:UK

Posted 01 July 2013 - 09:33 AM

$order->orderDetails will return an array of objects, not an object. Depending on what you're doing in the view, you might want to try using a CArrayDataProvider instead.
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