IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MkFramework Discussion :

Problème de mise a jour des données avec mkframeworkPackage-1.2.0


Sujet :

MkFramework

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2006
    Messages : 35
    Points : 28
    Points
    28
    Par défaut Problème de mise a jour des données avec mkframeworkPackage-1.2.0
    je travail sur une application avec mkframeworkPackage-1.2.0, j'ai importer abstract_rownoincrement et abstract_modelnoincrement. toutefois, je rencontre un problème dans la mise à jour des données. Voila l'erreur quand je clique "Edit" et que je valide

    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe pr�s de 'WHERE Type_Panne='LOGICIELS'' � la ligne 1
    #0 [internal function]: exception_error_handler(2, 'PDOStatement::e...', 'C:\\wamp64\\www\\m...', 251, Array)
    #1 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php(251): PDOStatement->execute(Array)
    #2 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php(204): abstract_sgbd_pdo->query('UPDATE type_pan...', Array)
    #3 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_modelnoincrement.php(171): abstract_sgbd_pdo->update('type_panne', Array, Array)
    #4 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php(65): abstract_modelnoincrement->update(Object(row_type_panne))
    #5 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php(54): abstract_rownoincrement->update()
    #6 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\model\model_type_panne.php(79): abstract_rownoincrement->save()
    #7 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\module\BackOffice\main.php(1088): row_type_panne->save()
    #8 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\module\BackOffice\main.php(1029): module_BackOffice->TypePanneProcessSave()
    #9 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\class_root.php(264): module_BackOffice->_TypePanneEdit()
    #10 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\public\index.php(48): _root->run()
    #11 {main}
     
    Detail:
    #0 exception_error_handler( , 'PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe pr�s de 'WHERE Type_Panne='LOGICIELS'' � la ligne 1' , 'C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php' , , Array ( [sReq] => UPDATE type_panne SET WHERE Type_Panne=? [tParam] => Array ( [0] => LOGICIELS ) [tATTRERRMODE] => Array ( [SILENT] => 0 [WARNING] => 1 [EXCEPTION] => 2 ) [tATTRCASE] => Array ( [LOWER] => 2 [NATURAL] => 0 [UPPER] => 1 ) [sth] => PDOStatement Object ( [queryString] => UPDATE type_panne SET WHERE Type_Panne=? ) ) ) 
    #1 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php (251) 
    PDOStatement -> execute( Array ( [0] => LOGICIELS ) ) 
    #2 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php (204) 
    abstract_sgbd_pdo -> query( 'UPDATE type_panne SET WHERE Type_Panne=?' , Array ( [0] => LOGICIELS ) ) 
    #3 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_modelnoincrement.php (171) 
    abstract_sgbd_pdo -> update( 'type_panne' , Array ( ) , Array ( [Type_Panne] => LOGICIELS ) ) 
    #4 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php (65) 
    abstract_modelnoincrement -> update( ) 
    #5 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php (54) 
    abstract_rownoincrement -> update( ) 
    #6 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\model\model_type_panne.php (79) 
    abstract_rownoincrement -> save( ) 
    #7 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\module\BackOffice\main.php (1088) 
    row_type_panne -> save( ) 
    #8 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\module\BackOffice\main.php (1029) 
    module_BackOffice -> TypePanneProcessSave( ) 
    #9 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\class_root.php (264) 
    module_BackOffice -> _TypePanneEdit( ) 
    #10 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE\public\index.php (48) 
    _root -> run( ) 
    #11 {main}
    Fichier : C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php ligne 251
     
    Message : PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe pr�s de 'WHERE Type_Panne='LOGICIELS'' � la ligne 1
     
    233	        $tATTRERRMODE=array(
    234	            'SILENT' => PDO::ERRMODE_SILENT,
    235	            'WARNING' => PDO::ERRMODE_WARNING,
    236	            'EXCEPTION' => PDO::ERRMODE_EXCEPTION,
    237	        );
    238	        $tATTRCASE=array(
    239	            'LOWER' => PDO::CASE_LOWER,
    240	            'NATURAL' => PDO::CASE_NATURAL,
    241	            'UPPER' => PDO::CASE_UPPER,
    242	        );
    243	        
    244	        
    245	        $this->connect();
    246	        $this->_sReq=$sReq.' [ '.implode(' | ',$tParam).' ]';
    247	        $this->_pDb->setAttribute(PDO::ATTR_ERRMODE, $tATTRERRMODE[ trim(_root::getConfigVar('pdo.ATTR_ERRMODE','WARNING')) ] ); 
    248	        $this->_pDb->setAttribute(PDO::ATTR_CASE, $tATTRCASE[ trim(_root::getConfigVar('pdo.ATTR_CASE','NATURAL')) ] ); 
    249	        $sth = $this->_pDb->prepare($sReq);
    250	        if(is_array($tParam)){
    251	            $sth->execute($tParam);
    252	        }else{
    253	            $sth->execute();
    254	        }
    255	        return $sth;
    256	    }
    257	
    258	    public function erreur($sErreur){
    259	        throw new Exception($sErreur);
    260	    }
    261	    
    262	}
    263	
    Navigation
    Module:BackOffice Action:TypePanneEdit
    $_GET
    Array
    (
    [:nav] => BackOffice::TypePanneEdit
    [id] => LOGICIEL
    )
    $_POST
    Array
    (
    [Type_Panne] => LOGICIELS
    [token] => 1564737718####fb073bf3ffc6ca7d66017e4038a8310e171638ff
    )
    $_SESSION
    Array
    (
    [ip] => 363baea9cba210afac6d7a556fca596e30c46333
    [userAgent] => 2be656b3d3df93074ecc211833c40fbe2f39f591
    [timeout] => 1564739528
    [oAccount] => O:8:"row_user":4:{s:14:"*sClassModel";s:10:"model_user";s:28:"abstract_row_bChooseUpdate";b:1;s:13:"*_tProperty";a:4:{s:7:"User_ID";s:1:"1";s:10:"User_Login";s:4:"edja";s:13:"User_Password";s:40:"ae1c6bfd5c3839c765ab7c1bc00572167375e7bf";s:9:"GROUPS_ID";s:1:"1";}s:21:"*_tPropertyToUpdate";N;}
    [login] => edja
    [groupe] => Administrateur
    [userId] => 1
    )
    $_SERVER
    Array
    (
    [HTTP_HOST] => localhost
    [HTTP_CONNECTION] => keep-alive
    [CONTENT_LENGTH] => 89
    [HTTP_CACHE_CONTROL] => max-age=0
    [HTTP_ORIGIN] => <a href="http://localhost" target="_blank">http://localhost</a>
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [CONTENT_TYPE] => application/x-www-form-urlencoded
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
    [HTTP_REFERER] => <a href="http://localhost/mkframeworkPackage-1.2.0/Projects/ParcInfoMAE/public/index.php?:nav=BackOffice::TypePanneEdit&id=LOGICIEL" target="_blank">http://localhost/mkframeworkPackage-...it&id=LOGICIEL</a>
    [HTTP_ACCEPT_ENCODING] => gzip, deflate, br
    [HTTP_ACCEPT_LANGUAGE] => fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
    [HTTP_COOKIE] => PHPSESSID=us4e4i97dcl0llh91h97ehfbrn; _ga=GA1.1.2049507022.1524831686; __utma=111872281.2049507022.1524831686.1529424019.1553090468.82; __utmz=111872281.1553090468.82.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); SnapABugHistory=1#; _gid=GA1.1.2053781111.1564390918; _gat=1
    [PATH] => C:\app\Administrateur\product\11.2.0\client_1\bin;C:\ProgramData\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\ComposerSetup\bin;C:\wamp64\bin\php\php7.1.9;C:\Windows\system32;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\Administrateur.MAE-ADMIN\AppData\Roaming\Composer\vendor\drush\drush;c:/wamp64/bin/php/php7.1.9/php.exe;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_191\bin;C:\Program Files\nodejs\;C:\Program Files\PuTTY\;
    [SystemRoot] => C:\Windows
    [COMSPEC] => C:\Windows\system32\cmd.exe
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    [WINDIR] => C:\Windows
    [SERVER_SIGNATURE] =>
    Apache/2.4.27 (Win64) PHP/7.1.9 Server at localhost Port 80
     
     
    [SERVER_SOFTWARE] => Apache/2.4.27 (Win64) PHP/7.1.9
    [SERVER_NAME] => localhost
    [SERVER_ADDR] => ::1
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => ::1
    [DOCUMENT_ROOT] => C:/wamp64/www
    [REQUEST_SCHEME] => http
    [CONTEXT_PREFIX] => 
    [CONTEXT_DOCUMENT_ROOT] => C:/wamp64/www
    [SERVER_ADMIN] => <a href="mailto:wampserver@wampserver.invali">wampserver@wampserver.invali</a>d
    [SCRIPT_FILENAME] => C:/wamp64/www/mkframeworkPackage-1.2.0/Projects/ParcInfoMAE/public/index.php
    [REMOTE_PORT] => 49734
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => POST
    [QUERY_STRING] => :nav=BackOffice::TypePanneEdit&id=LOGICIEL
    [REQUEST_URI] => /mkframeworkPackage-1.2.0/Projects/ParcInfoMAE/public/index.php?:nav=BackOffice::TypePanneEdit&id=LOGICIEL
    [SCRIPT_NAME] => /mkframeworkPackage-1.2.0/Projects/ParcInfoMAE/public/index.php
    [PHP_SELF] => /mkframeworkPackage-1.2.0/Projects/ParcInfoMAE/public/index.php
    [REQUEST_TIME_FLOAT] => 1564737728.079
    [REQUEST_TIME] => 1564737728
    )

  2. #2
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Bonjour,
    d'apres la requete

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    UPDATE type_panne SET WHERE Type_Panne=?
    l'objet ne doit pas avoir de champ modifié d'ou le soucis lors de l'update en base de donnée

    Il faut au minimum modifier un champ de l'objet pour que l'update fonctionne bien
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2006
    Messages : 35
    Points : 28
    Points
    28
    Par défaut
    ça suppose si je n'abuse que toutes les tables doivent avoir un Id automatique

  4. #4
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Non, je voulais dire que l'erreur est produite car aucun champ de l'objet n'a été mis à jour

    pour optimiser les requetes, les update ne sont fait que sur les champs modifiés dans l'objet

    ainsi, meme sur une table de 15 champs, si on modifie uniquement le champ titre, seul celui-ci sera updaté

    Puis-je voir le code du fichier main:

    Projects\ParcInfoMAE\module\BackOffice\main.php autour de la ligne 1088

    je suppose la méthode processSave
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2006
    Messages : 35
    Points : 28
    Points
    28
    Par défaut
    aussi, je pense que pour résoudre se problème, le module de génération de la vue Edit doit ajouter un champs caché qui récupère l'Id. puis tous les traitement seront fait sur ce champs comme ça on évitera cette erreur et l'obligation d'avoir des id automatiques....

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2006
    Messages : 35
    Points : 28
    Points
    28
    Par défaut
    voici le contenu de mon fichier main

    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    //-----------------------------------------------------------------Gestion des Types de Panne----------------------------------------------------------------------//
        public function _TypePanneList(){
     
    		$tType_panne=model_type_panne::getInstance()->findAll();
     
    		$oView=new _view('BackOffice::TypePanneList');
    		$oView->tType_panne=$tType_panne;
     
     
    		$this->oLayout->add('main',$oView);
     
    	}
     
     
    	public function _TypePanneNew(){
    		$tMessage=$this->TypePanneProcessSave();
     
    		$oType_panne=new row_type_panne;
     
    		$oView=new _view('BackOffice::TypePanneNew');
    		$oView->oType_panne=$oType_panne;
     
     
    		$oPluginXsrf=new plugin_xsrf();
    		$oView->token=$oPluginXsrf->getToken();
    		$oView->tMessage=$tMessage;
     
    		$this->oLayout->add('main',$oView);
    	}
     
     
     
    	public function _TypePanneEdit(){
    		$tMessage=$this->TypePanneProcessSave();
     
    		$oType_panne=model_type_panne::getInstance()->findById( _root::getParam('id') );
     
    		$oView=new _view('BackOffice::TypePanneEdit');
    		$oView->oType_panne=$oType_panne;
    		$oView->tId=model_type_panne::getInstance()->getIdTab();
     
     
    		$oPluginXsrf=new plugin_xsrf();
    		$oView->token=$oPluginXsrf->getToken();
    		$oView->tMessage=$tMessage;
     
    		$this->oLayout->add('main',$oView);
    	}
     
     
     
    	public function _TypePanneDelete(){
    		$tMessage=$this->TypePanneProcessDelete();
     
    		$oType_panne=model_type_panne::getInstance()->findById( _root::getParam('id') );
     
    		$oView=new _view('BackOffice::TypePanneDelete');
    		$oView->oType_panne=$oType_panne;
     
     
    		$oPluginXsrf=new plugin_xsrf();
    		$oView->token=$oPluginXsrf->getToken();
    		$oView->tMessage=$tMessage;
     
    		$this->oLayout->add('main',$oView);
    	}
     
     
     
    	private function TypePanneProcessSave(){
    		if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
    			return null;
    		}
     
    		$oPluginXsrf=new plugin_xsrf();
    		if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
    			return array('token'=>$oPluginXsrf->getMessage() );
    		}
     
    		$iId=_root::getParam('id',null);
    		if($iId==null){
    			$oType_panne=new row_type_panne;	
    		}else{
    			$oType_panne=model_type_panne::getInstance()->findById( _root::getParam('id',null) );
    		}
     
    		$tColumn=array('Type_Panne');
    		foreach($tColumn as $sColumn){
    			$oType_panne->$sColumn=_root::getParam($sColumn,null) ;
    		}
     
     
    		if($oType_panne->save()){
    			//une fois enregistre on redirige (vers la page liste)
    			_root::redirect('BackOffice::TypePanneList');
    		}else{
    			return $oType_panne->getListError();
    		}
     
    	}
     
     
    	public function TypePanneProcessDelete(){
    		if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
    			return null;
    		}
     
    		$oPluginXsrf=new plugin_xsrf();
    		if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
    			return array('token'=>$oPluginXsrf->getMessage() );
    		}
     
    		$oType_panne=model_type_panne::getInstance()->findById( _root::getParam('id',null) );
     
    		$oType_panne->delete();
    		//une fois enregistre on redirige (vers la page liste)
    		_root::redirect('BackOffice::TypePanneList');
     
    	}

  7. #7
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    En regardant le code on voit le soucis ici:

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    $tColumn=array('Type_Panne');
    foreach($tColumn as $sColumn){
    $oType_panne->$sColumn=_root::getParam($sColumn,null) ;
    }

    il y a un seul champ mis à jour ici c'est le champ Type_Panne

    hors quel est le champ d'identification de cette table ?

    IL faut 2 champs au minimum: un champ d'identification et un champ de contenu, sinon en effet ça ne peut pas marcher
    Dans votre cas, il faudrait (comme vous l'indiquiez) sans doute ajouter un champ d'id incrémental
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  8. #8
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2006
    Messages : 35
    Points : 28
    Points
    28
    Par défaut
    Merci,. mais est-ce-qu'on ne peut pas envisager ceci:

    lors de la génération de la vue Edit, qu'il y ai un champ hidden qui recupère l'ID comme dans mon cas. et qte la clause where soit basée sur se champs hidden tan disque la valeur à modifier reste "Type_panne"

    cordialement

  9. #9
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Bonjour,
    Je pense qu'il y a un quiproquo

    vous parlez d'ajouter un champ hidden contenant l'id, mais on a l'equivalent ici avec l'id dans la barre d'url
    le problème est ailleursl:

    habituellement vous avez au minium 2 champs pour une table: un identifiant et N champs de contenu
    on peut ainsi dans un formulaire faire un édit avec l'id de l'enregistrement et modifier un ou plusiuers champs provoquant une requete SQL du type:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    UPDATE MA_TABLE SET MON_CHAMP=ma_valeur WHERE MON_ID=L_IDENTIFIANT
    hors ici, on se retrouve avec apparement un seul champ sur la table d'ou le soucis: il faut au minium un id et un champ de valeur pour que la génération de CRUD fonctionne ici

    oui je pourrais faire une modification mais elle est impactante pour tous les autres utilisateurs, c'est ça le soucis

    sinon dans votre cas il faudrait modifier le fichier main.php pour ne pas utiliser la fonction save mais ecrire une methode particulière

    ou sinon il faudrait modifier la classe modèle du framework: abstract_modelnoincrement

    pour remplacer
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    public function update($oRow){
    		$tColumnToUpdate=$oRow->getToUpdate();
    		unset($tColumnToUpdate[$this->tId[0] ]);
    		$this->getSgbd()->update($this->sTable,$tColumnToUpdate,$oRow->getWhere());
    		/*LOG*/_root::getLog()->info('sql update:'.$this->getSgbd()->getRequete());
    	}

    par

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    public function update($oRow){
    		$tColumnToUpdate=$oRow->getToUpdate();
    		//unset($tColumnToUpdate[$this->tId[0] ]);
    		$this->getSgbd()->update($this->sTable,$tColumnToUpdate,$oRow->getWhere());
    		/*LOG*/_root::getLog()->info('sql update:'.$this->getSgbd()->getRequete());
    	}

    et ainsi cela devrait fonctionner
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  10. #10
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2006
    Messages : 35
    Points : 28
    Points
    28
    Par défaut toujours problème
    Bonjour imicado, j'ai appliqué la solution, mais elle n'a pas marché. La résolution de ce problème est très capital. En fait je travail sur un projet de mon ministère. J'ai des tables issues d'une hierachisation-spécialisation, et je n'arrive pas à mettre toujour à jour ces tables. Toujours une erreur



    //----------------------------------------------------------------erreur------------------------------------------------------------------------------------

    PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
    #0 [internal function]: exception_error_handler(2, 'PDOStatement::e...', 'C:\\wamp64\\www\\m...', 251, Array)
    #1 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php(251): PDOStatement->execute(Array)
    #2 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php(204): abstract_sgbd_pdo->query('UPDATE ordinate...', Array)
    #3 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_modelnoincrement.php(177): abstract_sgbd_pdo->update('ordinateur', Array, Array)
    #4 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php(65): abstract_modelnoincrement->update(Object(row_ordinateur))
    #5 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php(54): abstract_rownoincrement->update()
    #6 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\model\model_ordinateur.php(79): abstract_rownoincrement->save()
    #7 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\module\BackOffice\main.php(3079): row_ordinateur->save()
    #8 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\module\BackOffice\main.php(3016): module_BackOffice->OrdinateurProcessSave()
    #9 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\class_root.php(264): module_BackOffice->_OrdinateurEdit()
    #10 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\public\index.php(48): _root->run()
    #11 {main}

    Detail:
    #0 exception_error_handler( , 'PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' , 'C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php' , , Array ( [sReq] => UPDATE ordinateur SET `TypeOrdinateur`=?,`MicroIntegre`=?,`EnceinteIntegre`=?,`Materiel_SN`=? WHERE Materiel_SN=? [tParam] => Array ( [0] => ORDINATEUR DE BUREAU [1] => NON [2] => OUI [3] => CZC62485B0 ) [tATTRERRMODE] => Array ( [SILENT] => 0 [WARNING] => 1 [EXCEPTION] => 2 ) [tATTRCASE] => Array ( [LOWER] => 2 [NATURAL] => 0 [UPPER] => 1 ) [sth] => PDOStatement Object ( [queryString] => UPDATE ordinateur SET `TypeOrdinateur`=?,`MicroIntegre`=?,`EnceinteIntegre`=?,`Materiel_SN`=? WHERE Materiel_SN=? ) ) )
    #1 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php (251)
    PDOStatement -> execute( Array ( [0] => ORDINATEUR DE BUREAU [1] => NON [2] => OUI [3] => CZC62485B0 ) )
    #2 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_sgbd_pdo.php (204)
    abstract_sgbd_pdo -> query( 'UPDATE ordinateur SET `TypeOrdinateur`=?,`MicroIntegre`=?,`EnceinteIntegre`=?,`Materiel_SN`=? WHERE Materiel_SN=?' , Array ( [0] => ORDINATEUR DE BUREAU [1] => NON [2] => OUI [3] => CZC62485B0 ) )
    #3 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_modelnoincrement.php (177)
    abstract_sgbd_pdo -> update( 'ordinateur' , Array ( [TypeOrdinateur] => ORDINATEUR DE BUREAU [MicroIntegre] => NON [EnceinteIntegre] => OUI [Materiel_SN] => CZC62485B0 ) , Array ( [Materiel_SN] => CZC62485B0 ) )
    #4 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php (65)
    abstract_modelnoincrement -> update( )
    #5 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\abstract\abstract_rownoincrement.php (54)
    abstract_rownoincrement -> update( )
    #6 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\model\model_ordinateur.php (79)
    abstract_rownoincrement -> save( )
    #7 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\module\BackOffice\main.php (3079)
    row_ordinateur -> save( )
    #8 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\module\BackOffice\main.php (3016)
    module_BackOffice -> OrdinateurProcessSave( )
    #9 C:\wamp64\www\mkframeworkPackage-1.2.0\Lib\mkframeworkLib\class_root.php (264)
    module_BackOffice -> _OrdinateurEdit( )
    #10 C:\wamp64\www\mkframeworkPackage-1.2.0\Projects\ParcInfoMAE - V2\public\index.php (48)
    _root -> run( )
    #11 {main}

  11. #11
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Bonjour,
    j'ai trouvé une solution: mais il faut pour l'instant modifier un fichier du framework,

    la classe abstract/abstract_sgbd_pdo.php

    remplacer
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    public function update($sTable,$tProperty,$tWhere){
     
    		$sReq='UPDATE '.$sTable.' SET '.$this->getUpdateFromTab($tProperty).' WHERE '.$this->getWhereFromTab($tWhere);
     
    		$tPropertyAndWhere=array_merge($tProperty,$tWhere);
    		$tParam=array_values($tPropertyAndWhere);
     
    		$this->query($sReq,$tParam);
    	}

    par
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    public function update($sTable,$tProperty,$tWhere){
     
    		$sReq='UPDATE '.$sTable.' SET '.$this->getUpdateFromTab($tProperty).' WHERE '.$this->getWhereFromTab($tWhere);
     
    		$tPropertyAndWhere=array_merge(array_values($tProperty),array_values($tWhere));
    		$tParam=array_values($tPropertyAndWhere);
     
    		$this->query($sReq,$tParam);
    	}

    Mais je repose ma question: pourquoi ne pas ajouter un champ id incrémtal ?
    car la je sais pas à quoi sert cette table, mais on ne peut pas avoir de jointeure avec cette table. Par exemple, si on voudrais changer l'intitulé du type de panne, pour changer l'affichage de toutes les interventions liés à celle-ci on ne peut pas

    En tout cas j'espère que ce patch reglera votre soucis
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

Discussions similaires

  1. [AC-2003] Problème de mise jour à des données avec ADO
    Par @omzo dans le forum VBA Access
    Réponses: 2
    Dernier message: 24/06/2010, 14h25
  2. mise a jour des données impossible avec soapconnection
    Par amireve dans le forum Web & réseau
    Réponses: 10
    Dernier message: 04/02/2010, 20h28
  3. Mise a jour des données sans se deconnecter
    Par djedie dans le forum Requêtes
    Réponses: 1
    Dernier message: 16/10/2006, 13h57
  4. mise a jour des colones avec smo
    Par casimir24 dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 12/12/2005, 16h13
  5. mise a jours des données sous access
    Par puyopuyo dans le forum ASP
    Réponses: 4
    Dernier message: 25/05/2004, 13h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo