Yii Framework Forum: Saving Ar Object Between Requests - Yii Framework Forum

Jump to content

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

Saving Ar Object Between Requests

#1 User is offline   tidy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-March 14

Posted 18 March 2014 - 09:47 AM

Hello
What is the best way to save AR object between requests without saving it to DB?
What I want
Request 1
$item = Items::model()->finsByPk($id);
Request 2
$item->some_property = x; // with some internal business logic, some fields changes
Request 3
$item->another_property = y;
Request 4
here i want to be able to do or
$item->save();
or just clear the object and left corresponding database record unchanged

I've tried to save it to the session like this
Yii::app()->user->setState('item',$item);
or
Yii::app()->session['item'] = $item;

All is goig fine untill i try to save it to db. After save method i'm getting Access violation errors in my php process.
So what is the best solution in this situation?
0

#2 User is offline   Boaz 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 367
  • Joined: 23-January 11

Posted 18 March 2014 - 09:59 AM

First, this is not the forum for this kind of question. I guess the admins will soon move it to the right forum ("General v1.x questions"...).
To your question, see the short example on how to use CHttpSession on its api documentation page.
Therapeutic PHP sessions My LinkedIn Profile
0

#3 User is offline   tidy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-March 14

Posted 18 March 2014 - 11:57 AM

View PostBoaz, on 18 March 2014 - 09:59 AM, said:

First, this is not the forum for this kind of question. I guess the admins will soon move it to the right forum ("General v1.x questions"...).
To your question, see the short example on how to use CHttpSession on its api documentation page.


Oops. Sorry for my mistake. I saw the title "Web Application Development With Yii And PHP" but haven't noticed "Yii Books Discussion". My topic must be deleted at all, because my session code is ok. As I've found out my PDO library is the memory corruption reason.
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