Bonjour,
J'ai ce array :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
$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,
		)
);
Je le parcours ainsi pour faire des insertions dans ma bdd
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
function remplir_dbb($array) {
	foreach ($array as $data) {
		foreach ($data as $value) {
			insertValidateur($value);
			if ( isset($value['sub']) && is_array($value['sub']) ) {
				remplir_dbb($value['sub']);
			}
		}
	}
}
 
remplir_dbb($myArray);
Message d'erreur :
( ! ) Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'login' cannot be null' in I:\wamp2\www\validation\index.php on line 285
( ! ) PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'login' cannot be null in I:\wamp2\www\validation\index.php on line 285
D'où pourrait provenir cette erreur ?
[EDIT]
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
function insertValidateur($array) {
	global $db;
	$return = false;
	$sql = 'INSERT INTO validateurs (login, pswd, salt) VALUES (:login, :pswd, :salt)';
	$statement = $db->prepare($sql);
	if ( $statement->execute(array(':login' => $array['structure_login'], ':pswd' => $array['structure_pswd'], ':salt' => $array['structure_salt'])) ) { $return = true;}
	return $return;
}
Merci d'avance...