开发者

Simulate saving propel object (Don't write into tables)

I have a functionality in my project where in I have to show a preview to the user as to how the page will look like after submitting the form. For preview, I am setting related propel object with the form values and in the end not saving any values as this is only a preview.

This works, but the previous values of related table get deleted and after preview all related tables are not restored to their previous state as I am not saving the object. Please, is this a bug? I don't want to save any of the values to any table, but just use the object to show the preview.

Is there proper way of doing 开发者_开发技巧this.

EDIT: I will rephrase this question. If I don't save the propel object, will the changes be affected in the tables?. Right now, if I don't save, the main table is unaffected but the relations are affected and not restored to old values if object is not saved.

Eg: I have two tables, job and jobsectors with foreign key relationship. I do $job->addJobsector('someSector');

I don't save the object, but the previous value in jobsector is deleted and there is no new value.

Thanks


I resolved it. Whenever functions starting with initTablename() are used, it seems the previous values were getting deleted. I just don't call these functions for preview. And not saving the object will not store any data to database.

Thanks


Try with a transaction: start a transaction, then save all the needed data, display what you need and rollback the transaction. So, anything you did in you transaction (saving, deleting) is stored in the database

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜