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
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_id
has the same value all the time.
No comments:
Post a Comment