Search code examples
phpmysqlsymfony1propel

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


Solution

  • 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