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 :

Impossible de mettre à jour un enregistrement


Sujet :

MkFramework

  1. #1
    Membre régulier
    Femme Profil pro
    Étudiant
    Inscrit en
    Septembre 2015
    Messages
    304
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Gabon

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2015
    Messages : 304
    Points : 107
    Points
    107
    Par défaut Impossible de mettre à jour un enregistrement
    Bonjour,

    J'essaye de fait un edit sur un enregistrement mais je n'y arrive pas. Je crois que le problème vient de la fonction save().
    Voici l'état des choses: j'ai un module candidatures dans lequel j'ai dupliqué la fonction processSave en deux: l'une pour la fonction'_new()' et l'autre pour la fonction '_edit()'. voici cette dernière:
    Code php : 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
    public function _edit(){
    		$tMessage=$this->processEdit();
     
    		$oCandidatures=model_candidatures::getInstance()->findById( _root::getParam('id') );
     
    		$oView=new _view('candidatures::edit');
    		$oView->oCandidatures=$oCandidatures;
    		$oView->tId=model_candidatures::getInstance()->getIdTab();
     
    				$oView->tJoinmodel_candidats=model_candidats::getInstance()->getSelect();		$oView->tJoinmodel_utilisateurs=model_utilisateurs::getInstance()->getSelect();		$oView->tJoinmodel_statut_cands=model_statut_cands::getInstance()->getSelect();
     
    		$oPluginXsrf=new plugin_xsrf();
    		$oView->token=$oPluginXsrf->getToken();
    		$oView->tMessage=$tMessage;
     
    		$this->oLayout->add('main',$oView);
    		$this->oLayout->title="e-tmg - Modification de candidature";
    	}
    private function processEdit(){
    		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){
    			$oCandidatures=new row_candidatures;	
    		}else{
    			$oCandidatures=model_candidatures::getInstance()->findById( _root::getParam('id',null) );
    		}
     
     
    		$tColumnUpload=array('lettre_motivation');
    		if($tColumnUpload){
    			foreach($tColumnUpload as $sColumnUpload){
    				$oPluginUpload=new plugin_upload($sColumnUpload);
    				if($oPluginUpload->isValid()){
    					$sNewFileName=_root::getConfigVar('path.upload').$sColumnUpload.'_c_'.$oCandidatures->candidat_id.'_p_'.$oCandidatures->poste_id.'_'.date('Ymdhis');
     
    					$oPluginUpload->saveAs($sNewFileName);
    					$oCandidatures->$sColumnUpload=$oPluginUpload->getPath();
    				}
    			}
    		}
     
     
    		if($oCandidatures->save()){
    			//une fois enregistre on redirige (vers la page liste)
    			_root::redirect('comptes::gestCandidature');
    		}else{
    			return $oCandidatures->getListError();
    		}
     
    	}
    Lorsque je valide la vue 'edit.php' j'ai ce message
    PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='13'' at line 1
    #0 [internal function]: exception_error_handler(2, 'PDOStatement::e...', 'C:\\xampp\\htdocs...', 251, Array)
    #1 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_sgbd_pdo.php(251): PDOStatement->execute(Array)
    #2 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_sgbd_pdo.php(204): abstract_sgbd_pdo->query('UPDATE candidat...', Array)
    #3 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_model.php(169): abstract_sgbd_pdo->update('candidatures', Array, Array)
    #4 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_row.php(64): abstract_model->update(Object(row_candidatures))
    #5 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_row.php(54): abstract_row->update()
    #6 C:\xampp\htdocs\MKF\data\genere\e-tmg\model\model_candidatures.php(103): abstract_row->save()
    #7 C:\xampp\htdocs\MKF\data\genere\e-tmg\module\candidatures\main.php(193): row_candidatures->save()
    #8 C:\xampp\htdocs\MKF\data\genere\e-tmg\module\candidatures\main.php(58): module_candidatures->processEdit()
    #9 C:\xampp\htdocs\MKF\lib\framework\class_root.php(263): module_candidatures->_edit()
    #10 C:\xampp\htdocs\MKF\data\genere\e-tmg\public\index.php(47): _root->run()
    #11 {main}

    Detail:
    #0 exception_error_handler( , 'PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='13'' at line 1' , 'C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_sgbd_pdo.php' , , Array ( [sReq] => UPDATE candidatures SET WHERE id=? [tParam] => Array ( [0] => 13 ) [tATTRERRMODE] => Array ( [SILENT] => 0 [WARNING] => 1 [EXCEPTION] => 2 ) [tATTRCASE] => Array ( [LOWER] => 2 [NATURAL] => 0 [UPPER] => 1 ) [sth] => PDOStatement Object ( [queryString] => UPDATE candidatures SET WHERE id=? ) ) )
    #1 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_sgbd_pdo.php (251)
    PDOStatement -> execute( Array ( [0] => 13 ) )
    #2 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_sgbd_pdo.php (204)
    abstract_sgbd_pdo -> query( 'UPDATE candidatures SET WHERE id=?' , Array ( [0] => 13 ) )
    #3 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_model.php (169)
    abstract_sgbd_pdo -> update( 'candidatures' , Array ( ) , Array ( [id] => 13 ) )
    #4 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_row.php (64)
    abstract_model -> update( )
    #5 C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_row.php (54)
    abstract_row -> update( )
    #6 C:\xampp\htdocs\MKF\data\genere\e-tmg\model\model_candidatures.php (103)
    abstract_row -> save( )
    #7 C:\xampp\htdocs\MKF\data\genere\e-tmg\module\candidatures\main.php (193)
    row_candidatures -> save( )
    #8 C:\xampp\htdocs\MKF\data\genere\e-tmg\module\candidatures\main.php (58)
    module_candidatures -> processEdit( )
    #9 C:\xampp\htdocs\MKF\lib\framework\class_root.php (263)
    module_candidatures -> _edit( )
    #10 C:\xampp\htdocs\MKF\data\genere\e-tmg\public\index.php (47)
    _root -> run( )
    #11 {main}
    Fichier : C:\xampp\htdocs\MKF\lib\framework\abstract\abstract_sgbd_pdo.php ligne 251

    Message : PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='13'' at line 1
    Pouvez vous m'indiquer ce qui ne va pas?
    Merci pour les réponses

  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
    L'erreur vient du fait qu'aucune colonnes n'est updaté: il essaie de faire un update sans champ à updater
    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
    Membre régulier
    Femme Profil pro
    Étudiant
    Inscrit en
    Septembre 2015
    Messages
    304
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Gabon

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2015
    Messages : 304
    Points : 107
    Points
    107
    Par défaut
    Pourtant j'ai updaté un champ!
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    $tColumnUpload=array('lettre_motivation');
    		if($tColumnUpload){
    			foreach($tColumnUpload as $sColumnUpload){
    				$oPluginUpload=new plugin_upload($sColumnUpload);
    				if($oPluginUpload->isValid()){
    					$sNewFileName=_root::getConfigVar('path.upload').$sColumnUpload.'_c_'.$oCandidatures->candidat_id.'_p_'.$oCandidatures->poste_id.'_'.date('Ymdhis');
     
    					$oPluginUpload->saveAs($sNewFileName);
    					$oCandidatures->lettre_motivation=$oPluginUpload->getPath();
    				}
    			}
    		}

  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
    J'ai l'impression qu'il rentre pas dans le if (peut etre pas d'upload

    il execute donc pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $oCandidatures->lettre_motivation=$oPluginUpload->getPath();
    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
    Membre régulier
    Femme Profil pro
    Étudiant
    Inscrit en
    Septembre 2015
    Messages
    304
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Gabon

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2015
    Messages : 304
    Points : 107
    Points
    107
    Par défaut
    Effectivement, en commentant la condition comme ceci:
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    $tColumnUpload=array('lettre_motivation');
    		if($tColumnUpload){
    			foreach($tColumnUpload as $sColumnUpload){
    				$oPluginUpload=new plugin_upload($sColumnUpload);
    				//if($oPluginUpload->isValid()){
    					$sNewFileName=_root::getConfigVar('path.upload').$sColumnUpload.'_c_'.$oCandidatures->candidat_id.'_p_'.$oCandidatures->poste_id.'_'.date('Ymdhis');
     
    					$oPluginUpload->saveAs($sNewFileName);
    					$oCandidatures->lettre_motivation=$oPluginUpload->getPath();
    				//}
    			}
    		}
    La mise à jour passe en BDD. Quel est le risque dans ce cas? quelles sont les contraintes que doit vérifier l'objet $oPluginUpload pour être valide et donc sauvé en BDD?

  6. #6
    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
    Il verifie juste qu'il y a bien un fichier uploadé
    vu qu'il doit l'enregistrer physiquement si c'est le cas, vaut mieux verifier qu'il le recoit 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

  7. #7
    Membre régulier
    Femme Profil pro
    Étudiant
    Inscrit en
    Septembre 2015
    Messages
    304
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Gabon

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2015
    Messages : 304
    Points : 107
    Points
    107
    Par défaut
    Alors commenter la condition if n'est pas une bonne idée.
    Je l'ai dé-commenté, je suis retournée dans la page web et j'ai uploadé un nouveau fichier(candidatures::edit), lorsque je désire affiché ce fichier uploadé dans le navigateur j'ai un message spécifiant que l'objet n'a pas été trouvé. Et effectivement dans le dossier data/upload il n'y est pas.
    Comment faire pour qu'il y soit stocké alors? Je ne vois vraiment pas pourquoi l'upload ne s'effectue pas. Dans la table 'candidatures' le champs 'lettre_motivation' a été quand même modifié.
    Please help.

  8. #8
    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
    Le problème vient peut etre du formulaire, il doit etre de type multipart

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <form ...  method="post" enctype="multipart/form-data">
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  9. #9
    Membre régulier
    Femme Profil pro
    Étudiant
    Inscrit en
    Septembre 2015
    Messages
    304
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Gabon

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2015
    Messages : 304
    Points : 107
    Points
    107
    Par défaut
    Quel manque d'attention! en effet je n'avais pas renseigné cet attribut pour le formulaire.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 8
    Dernier message: 15/02/2008, 18h59
  2. Réponses: 1
    Dernier message: 23/01/2008, 14h27
  3. Réponses: 2
    Dernier message: 07/12/2007, 18h22
  4. Impossible de mettre à jour un champs
    Par _developpeur_ dans le forum Access
    Réponses: 4
    Dernier message: 23/01/2006, 13h17
  5. Réponses: 6
    Dernier message: 14/02/2003, 16h52

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