Buy Now
Sign in

problem: only saves the last record in the database

Fredolino , October 14 2020, 15:51
Fredolino 663
October 14 2020, 15:51 #394333
Hello,

i want to save data to the database and i have a save_data function.
The data is displayed in the debugger under "save_data_species".
But it only saves the last record in the database for me.
Can someone tell me where the problem is?

regards
F.
[save_data_species] => Array
(
[data] => Array
(
[0] => Array
(
[MTB_Art] => Array
(
[beo_art_id] => 2319
[count_species] => 1
[beof_id] => 1262
)

[MTB_Fundort] => Array
(
[mtb_id] => 2752
)

)

[1] => Array
(
[MTB_Art] => Array
(
[beo_art_id] => 1947
[count_species] => 4
[beof_id] => 1230
)

[MTB_Fundort] => Array
(
[mtb_id] => 3245
)

)

[2] => Array
(
[MTB_Art] => Array
(
[beo_art_id] => 2321
[count_species] => 1
[beof_id] => 1265
)

[MTB_Fundort] => Array
(
[mtb_id] => 3246
)

)

[3] => Array
(
[MTB_Art] => Array
(
[beo_art_id] => 1955
[count_species] => 1
[beof_id] => 1238
)

[MTB_Fundort] => Array
(
[mtb_id] => 5243
)

)

[TKnr] => 5243
[Species] => 1
)

[_success] => Data saved successfully
[log] => Array
(
[0] => INSERT INTO `mtb_map_germany` (`TKnr`, `Species`) values ('5243', '1') ON DUPLICATE KEY UPDATE `TKnr` = '5243',`Species` = '1';
)

[var] => Array
(
[TKnr] => 5243
[Species] => 1
[id] =>
)

)

)
admin 33
October 23 2020, 15:19 #394487
 Answer
The data source for the "Save data" is not formatted correctly, you have TKnr and Species fields, then you have an array of arrays, so it saves the fields and ignores the arrays, what do you expect to save exactly ?
Fredolino 663
October 23 2020, 16:25 #394492
 1
Hi,
yes, the Array-Problem is solved. :-)
Thanx
F.