I am trying to save data in CakePHP like this:
-
Get the maximum entry entry from table translations
(select from again as translations MAX (entry_id)) + 1 -
Translation table
$ translationData = array ('entry_id' => $ entry_id, 'language_id' = & gt; $ key; 'text' = & gt; $ item) ; $ Translation = new translation (); $ In translation & gt; Set ($ translationData); $ In translation & gt; Save ();Save the next set of data
Please see my code
> $ This- & gt; Request-> Data ['product'] ['name_tr_id'] = $ this- & gt; Translation-> Save translation ($ this- & amp; Request-> Data ['product'] ['name']); $ This- & gt; Request-> Data ['product'] ['description_tr_id'] = $ this- & gt; Translation-> Save TranslationLeisure ($ ---; -> '' '[' Product '] [' Description ']); $ This- & gt; Request-> Data ['product'] ['seo_title_tr_id'] = $ this- & gt; Translation-> Save TranslationLeisure ($ this- & amp; Request-> Data ['product'] ['seo_title']); $ This- & gt; Request-> Data ['product'] ['seo_keywords_tr_id'] = $ this- & gt; Translation-> Save transliteration ($ this- & amp; Request-> Data ['product'] ['seo_keywords']); $ This- & gt; Request-> Data ['product'] ['seo_desc_tr_id'] = $ this- & gt; Translation-> Save TranslationLeisure ($ this- & amp; Request-> Data ['product'] ['seo_desc']);Savings translate method:
Public function save translation ($ data) {$ entry_id = $ this- & gt; GetNextFreeId (); Forex currency ($ data as $ key => $ item) {if ($ item! = "") {$ This-> Create (); $ Temp ['translation'] ['entry_id'] = $ entryid; $ Temp ['translation'] ['language_id'] = $ key; $ Temp ['translation'] ['text'] = $ item; $ This- & gt; Save ($ temporary); }} $ Entry_id; }getNextFreeId method:
public function getNextFreeId () {$ result = $ this- & gt; Query ("Choose MAX (entry_id) res)"); The result of the return [0] [0] ['race'] + 1; }I do not know why
entry_idhas the same value all the time.
No comments:
Post a Comment