dynamic creating and mapping new field in doctrine/symfony/mysql -


For example "Y2014Q1" -

In each quarter (every 3 months) I had to add "News" to the "Report" table After making Y = year and question = quartle (1,2,3,4), I have to mapping this new column in the object.

My code is part of:

  named place backend \ backendbundle \ existence; Use the theory / ORM \ mapping as an ORM; / ** * FactSheetData * * @ORM \ Table (name = "report") * @ORM \ unit * / class ReportData {/ ** * @ integer * * @ORM \ column (name = "id", type = " Integer ") * @ORM \ Id * @ORM \ generated values ​​(strategy =" auto ") * / personal $ id; / ** * @string string * * @ORM \ column (name = "Y2016Q3", type = "string") * / personal $ Y2016Q3; / ** * @trust string $ Y2016Q3 * / Public function set Y2016Q3 ($ Y2016Q3) {$ this- & gt; Y2016Q3 = $ Y2016Q3; } / ** * @ Layer String * / Public Function getY2016Q4 () {Return $ this-> Y2016Q4; }  

....

.... I need to do something new when it comes:

  Square ReportData {public function __construct () {// if new period changes table (test_new_perriod) {$ new_period = 'Y2016Q4'; $ Sql ​​= "optional table" report 'add column' "$ new_period "` VARCHAR (50) zero default faucet; "; $ Stmt = $ this- & gt; GetEntityManager () - & gt; Mill Connection () - & gt; Ready ($ sql); $ Stmt- & gt; Executed (); // and now - how is this problem - dynamic mapping / ** * wave string * * @ORM \ column (name = "$ new_period", type = "string") * / private $ new_period; / ** * @trust string $ new_period * / public function set $ new_period ($ new_period) {$ this- & gt; $ New_period = $ new_period; } / ** * Get @ layer string * / public function $ new_period () {$ $ - $ new_period; }}}  

Hope I'll explain clearly ... Thanx for any advice.


Comments