I have an arrangement that I sent by AJAX to PHP to insert it into the database, the arrangement arrives to me in the following way:
$datas =
Array
(
[0] => Array
(
[0] => Array
(
[name] => fecha
[value] => 2016-08-10
)
)
[1] => Array
(
[0] => Array
(
[name] => identity
[value] => 11434058
)
)
[2] => Array
(
[0] => Array
(
[name] => company
[value] => 1
)
)
[3] => Array
(
[0] => Array
(
[name] => cc
[value] => 2
)
)
[4] => Array
(
[0] => Array
(
[name] => value
[value] => 6
)
)
[5] => Array
(
[0] => Array
(
[name] => qov
[value] => 1
)
)
[6] => Array
(
[0] => Array
(
[name] => concept
[value] => 3
)
)
[7] => Array
(
[0] => Array
(
[name] => land
[value] => 1
)
)
)
I have tried to go through it in order to save it in the database, the values [name]
are the names of the fields in the database with their respective values [value]
$datas = $request->getPost('datas');
foreach ($datas as $indices) {
$indice[$i] = $indices;
foreach ($indices as $identities) {
$identity[$j] = $identities;
$j++;
}
$this->saveAction($indice[$i], $i);
$i++;
}
//No he podido obtener esos valores en esta función hago la inserción
public function saveAction($val, $i) {
$fecha = $val[0]['name]['value'];
$new->fecha = $fecha;
if($new->save()){
$this->jsonResponseSuccess(
array(
'id' => $new->id), 201, 'Created'
);
}
}
I use phalcon framework, I do not know if I'm doing something wrong, I hope the question is understandable.