Yii Framework Forum: JSON based applicaton. how to replace AR in model? - Yii Framework Forum

Jump to content

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

JSON based applicaton. how to replace AR in model? Rate Topic: -----

#1 User is offline   Chris Wong 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-July 10

Posted 11 August 2010 - 04:35 AM

JSON/Array to "model" problem.

I'm working on an application which only deal with API(JSON data). no local database. I want to know if there are anyway to process JSON/Array data in "model"? It seems AR is meaningless for this. But how to keep using the lovely "$model->Products" and "attributeLabels"...?

Currently i only get/process the JSON data in controller and assign to "view". it's not using the yii power at all. and it's not MVC.

I search yii forum. and only found the following post. but it's not a complete solution.

http://www.yiiframew...__fromsearch__1


I'm a newbie. It's appricated if anyone can give me some hints or sample codes. Thanks.
0

#2 User is offline   PrplHaz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 28-September 09
  • Location:Boston, MA

Posted 11 August 2010 - 08:34 PM

I don't know how to solve your particular problem, but for the AR question, your model does not have to inherit from the ActiveRecord class, and instead can extend the CFormModel class:
http://www.yiiframew.../api/CFormModel

I'm guessing you could define your getter/setter methods in there based on the JSON model you're working with...
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