Bonjour;

J'ai deux table leurs structures comme suit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
Table LRU (ID_LRU, LRU) --> (int auto_increment, varchar)
Table article (ID-Article, designiation, ID_LRU) -->(varchar, varchar, int)
Je les rempli via deux fichiers xlsx. La table LRU elle prends pas en compte les mise à jour toujours 0 enregistrement.
J'ai essayé d'afficher la valeur de la requete après l'insertion est affiché 0, mon code est le suivant:

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  public function save(\...\Parse\Article $article, \...\Parse\LRU $lru ){
		$IdLRU=$lru->getId();
        $LRU=$lru->getLRU();
        $designation=$article->getDesigniation();
        $articleid= $article->getId();
        if ($LRU == "Unspecified") {
            $IdLRU = 40;
        } 
 
        else{
			//if ($LRU != 'new'){
				$check= $this->_db->query("SELECT `ID_LRU` FROM `lru` WHERE `LRU` ='".$LRU."'");
			//}
 
			if ($check->rowCount() == 0) {
				$this->_db->query("INSERT INTO `lru` (`ID_LRU`, `LRU`) VALUES ('".$IdLRU."', '".$LRU."');");
				$requete2 =$this->_db->query("SELECT `ID_LRU` FROM `lru` WHERE `LRU` ='".$LRU."'");
				while($data = $requete2->fetch())
				{
					$IdLRU=$data['ID_LRU'];
				}
			}
 
 
			else{
				while($data = $check->fetch())
				{
					$IdLRU=$data['ID_LRU'];
				}
			}
		}
        if ($articleid == 'DIEPRESTATION' || $articleid == 'DIEDIVBIEN' || $articleid == 'DIEDIVERS' ){
            if(!($this->_db->query("INSERT INTO `article` (`ID_Article`, `Designiation`, `ID_LRU`) VALUES ('".$articleid."', '".$designation."', '".$IdLRU."');")))
        {   
                if ($LRU != 'new'){
           return $this->_db->query(" UPDATE  `FLOOSE`.`article` SET  `ID_LRU` =  '".$IdLRU."' WHERE  `article`.`ID_Article` =  '".$articleid."' AND  `article`.`Designiation` =  '".$designation."' LIMIT 1 ;");
        }else {
        return false;}
        }
        else{
            return TRUE;
        }
        }
        else{
            if(!($this->_db->query("INSERT INTO `article` (`ID_Article`, `Designiation`, `ID_LRU`) VALUES ('".$articleid."', '', '".$IdLRU."');")))
        {if ($LRU != 'new'){
           return $this->_db->query(" UPDATE  `FLOOSE`.`article` SET  `ID_LRU` =  '".$IdLRU."' WHERE  `article`.`ID_Article` =  '".$articleid."' AND  `article`.`Designiation` =  '' LIMIT 1 ;");
        }else {
        return false;}
        }
        else{
            return TRUE;
        }
        }
 
 
    }
 
    public function saveAll(array $listArticle) {
        $count=0;
        foreach ($listArticle as $article) {
           if($this->save($article))
            $count++;
        }
		print_r($count); --------------------- ici m'a affiché 0----------------- 
        return $count;
    }

Le scénario est:

J'ai une classe Parse.php pour récuperer les données, dedans deux fonctions chacune pour un fichier.
Une classe ArticleDAO.php qui contient les getters et les setters.
Et le controlleur où j'importe les fichiers et j'appelle la classe ArticleDAO et Parse.
S'il vous plaît, le problème est-il de la requete est mal saisi ou y 'a un autre anomalie ?