1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
function insertValidateur($login, $pswd, $salt) {
global $db;
$return = false;
$sql = 'INSERT INTO validateurs (login, pswd, salt) VALUES (:login, :pswd, :salt)';
$statement = $db->prepare($sql);
if ( $statement->execute(array(':login' => $login, ':pswd' => $pswd, ':salt' => $salt)) ) { $return = true; }
return $return;
}
function remplir_dbb($array) {
foreach ($array as $data) {
//var_dump($data);
insertValidateur($data['structure_login'], $data['structure_pswd1'], $data['structure_libelle']);
if ( isset($data['sub']) && is_array($data['sub']) ) {
remplir_dbb($data['sub']);
}
}
}
$myArray = array (
0 => array (
'structure_id' => '160',
'structure_libelle' => 'Cabinet',
'structure_level' => '-1',
'structure_login' => '16-1-160-1',
'structure_pswd1' => 'iv0ih0e0',
'sub' => NULL,
),
1 => array (
'structure_id' => '161',
'structure_libelle' => 'Inspection Générale de l’Evaluation des Performances des Services',
'structure_level' => '-1',
'structure_login' => '16-1-161-1',
'structure_pswd1' => '01fadaex',
'sub' => array (
0 => array (
'structure_id' => '1',
'structure_libelle' => 'Délégation Départementale - Djérem',
'structure_level' => '2',
'structure_login' => '16-2-1-2',
'structure_pswd1' => 'wdhafmq5',
'sub' => NULL
),
1 => array (
'structure_id' => '1',
'structure_libelle' => 'Délégation Départementale - Djérem',
'structure_level' => '2',
'structure_login' => '16-2-1-2',
'structure_pswd1' => 'wdhafmq5',
'sub' => array (
0 => array (
'structure_id' => '1',
'structure_libelle' => 'Délégation Départementale - Djérem',
'structure_level' => '2',
'structure_login' => '16-2-1-2',
'structure_pswd1' => 'wdhafmq5',
'sub' => NULL
)
)
)
)
),
2 => array (
'structure_id' => '162',
'structure_libelle' => 'Inspection Générale de l’Evaluation du Fonctionnement des Services',
'structure_level' => '-1',
'structure_login' => '16-1-162-1',
'structure_pswd1' => '8kyalmle',
'sub' => NULL,
)
);
remplir_dbb($myArray); |
Partager