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

Zend_Db PHP Discussion :

pb chemin bdd [ZF 1.11]


Sujet :

Zend_Db PHP

  1. #21
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    oui j'allais oublié, j'utilise le $_name

  2. #22
    Membre averti Avatar de Njörd
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    190
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 190
    Points : 390
    Points
    390
    Par défaut
    Tout a fait, le setIntegrityCheck est dans des cas précis, principalement lors de jointure.

    Je te renvoi à cette discussion => Doit-on utiliser setIntegrityCheck

    Pour les insertions / suppressions :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    $tab  = array(
       'un_nom_de_colonne' => $variableDeCetteColone,
       'un_nom_de_colonne2' => $variableDeCetteColone2,
       ...
    );
     
    $this->insert($tab);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    $tab  = array(
       'un_nom_de_colonne' => $variableDeCetteColone,
       'un_nom_de_colonne2' => $variableDeCetteColone2,
       ...
    );
     
    $this->update($tab, 'id_annonce=' . $id_annonce);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $this->delete('id_annonce=' . $id_annonce);

  3. #23
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    c'est super bien expliqué.
    Je fais mes liens de table et je te tiens au courant ? j'ai du taff mdr

    c'est possible d'avoir ton mail si possible ( en message privé) stp enfin si tu veux

  4. #24
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    j'ai l'impression que c'est plus lisible comme code.

  5. #25
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    mais cela peut planter même si j'ai pas encore créer les autres models?

  6. #26
    Membre averti Avatar de Njörd
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    190
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 190
    Points : 390
    Points
    390
    Par défaut
    Normalement oui, puisque ton SGBD doit avoir ses propres règles de vérification quand il y a des relations.

    Je vais déco, bonne nuit

  7. #27
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    ok ca roule merci pour tout, je m'occupe de créer tous mes modèles ce soir.

    bonne nuit.

  8. #28
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    en commentant ton code et en ayant fait tous les models avec les foreign keys, j'ai encore une application error.

  9. #29
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    j'ai modifié la requête que tu m'avais envoyé

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     
    public function lireTout(){
            $select = $this->select()
                    ->setIntegrityCheck(false)
                    ->from(array('s' => 'service'),
    					   array('name','link_description','enable'));
     
     
            $result = $this->fetchAll($select);
     
            return $result->toArray();
        }
    comment je peux faire pour afficher chacun des champ dans mes td stp?

    merci d'avance.

  10. #30
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    ah ca c'est bon


  11. #31
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut Catchable fatal error: Object of class Application_Model_DbTable_Service could not be converted to string
    Bonjour,

    j'ai un petit soucis d'insertion.
    Puis je avoir un peu d'aide s'il vous plaît?

    j'ai l'erreur suivante :
    Catchable fatal error: Object of class Application_Model_DbTable_Service could not be converted to string in /usr/local/zend/share/ZendFramework/library/Zend/Db/Statement/Pdo.php on line 228

    Voici mon Db_table :

    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
     
     
    protected $_name = 'service';
     
        protected $_primary = 'id'; // genre id_****
    	protected $_dependentTables = array('Deviceservice');
     
        public function lireTout(){
            $select = $this->select()
                    ->setIntegrityCheck(false)
                    ->from(array('s' => 'service'),
    					   array('name','link_description','enable'));
     
     
            $result = $this->fetchAll($select);
     
            return $result->toArray();
        }
     
    	public function ajouterService($service, $description, $enable)
    	{
    			$data = array(
    			'name' => $service,
    			'link_description' => $description,
    			'enable' => $enable,
    			);
     
    			$this->insert($data);
    	}
    et mon controller:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     
    $model = new Application_Model_DbTable_Service();
    $this->view->service = $model->ajouterService();
    La clé primaire de service est transmise à la table device_service:

    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
     
            protected $_name = 'device_service';
    	protected $_primary = 'id';
     
    	protected $_referenceMap = array(
    		'Reporter' => array(
    		'columns' => 'id',
    		'refTableClass' => 'Service',
    		'refColumns' => 'id'
    		)
    	);
     
    	protected $_referenceMap = array(
    		'Reporter' => array(
    		'columns' => 'id',
    		'refTableClass' => 'Device',
    		'refColumns' => 'id'
    		)
    	);
    merci d'avance de votre aide.

    Cordialement,

  12. #32
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    autant pour moi, je me suis trompé d'action dans le controller :
    En remettant cela au bon endroit:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    $model = new Application_Model_DbTable_Service();
    $this->view->service = $model->ajouterService();
    j'ai une erreur :

    arning: Missing argument 1 for Application_Model_DbTable_Service::ajouterService(), called in /var/www/WebMRL/application/controllers/ConfigurationController.php on line 90 and defined in /var/www/WebMRL/application/models/DbTable/Service.php on line 23 Warning: Missing argument 2 for Application_Model_DbTable_Service::ajouterService(), called in /var/www/WebMRL/application/controllers/ConfigurationController.php on line 90 and defined in /var/www/WebMRL/application/models/DbTable/Service.php on line 23 Warning: Missing argument 3 for Application_Model_DbTable_Service::ajouterService(), called in /var/www/WebMRL/application/controllers/ConfigurationController.php on line 90 and defined in /var/www/WebMRL/application/models/DbTable/Service.php on line 23 Notice: Undefined variable: service in /var/www/WebMRL/application/models/DbTable/Service.php on line 26 Notice: Undefined variable: description in /var/www/WebMRL/application/models/DbTable/Service.php on line 27 Notice: Undefined variable: enable in /var/www/WebMRL/application/models/DbTable/Service.php on line 28


    merci d'avance de votre aide.

    Cordialement,

  13. #33
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut
    en remettant mon formulaire :


    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
     
     
    public function ajouterserviceAction()
        {
            // action body
    		Zend_Layout::getMvcInstance()->setLayout('layoutajoutserv');
     
    		$form = new Application_Form_Ajoutservice();
    		$form->envoyer->setLabel('Ajouter');
    		$this->view->form = $form;
    		if ($this->getRequest()->isPost()) {
    			$formData = $this->getRequest()->getPost();
    			if ($form->isValid($formData)) {
    				$service = $form->getValue('name');
    				$description = $form->getValue('link_description');
    				$enable = $form->getValue('enable');
     
    				$service = new Application_Model_DbTable_Service();
    				$service->ajouterService($service,$description,$enable);
    				$this->_redirect('/');
    			} else {
    				$form->populate($formData);
    			}
    		}
     
     
        }
    j'ai l'erreur :

    atchable fatal error: Object of class Application_Model_DbTable_Service could not be converted to string in /usr/local/zend/share/ZendFramework/library/Zend/Db/Statement/Pdo.php on line 228

    pourriez vous m'aider s'il vous plaît, merci d'avance.

  14. #34
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2012
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 118
    Points : 52
    Points
    52
    Par défaut problème insertion null zend php 5
    re bonjour,

    j'ai corrigé certaines choses.
    Mon problème est que j'insers des valeurs NULL.
    Pourriez vous me donne run coup de main s'il vous plaît ?

    Mon formulaire:

    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
     
    class Application_Form_Ajoutservice extends Zend_Form
    {
     
        public function init()
        {
            /* Form Elements & Other Definitions Here ... */
     
    		$id = new Zend_Form_Element_Hidden('id');
    		$service = new Zend_Form_Element_Text('name');
    		$service->setLabel('Service')
    				->setRequired(true)
    				->addFilter('StringTrim')
    				->addValidator('NotEmpty');
     
    		$description = new Zend_Form_Element_Text('link_description');
    		$description->setLabel('Description')
    			  ->setRequired(true)
    			  ->addFilter('StringTrim')
    			  ->addValidator('NotEmpty');
     
    	    $enable = new Zend_Form_Element_Checkbox('enable');
    		$enable->setLabel('Cochez si actif');
     
    		$envoyer = new Zend_Form_Element_Submit('envoyer');
    		$envoyer->setAttrib('id', 'boutonenvoyer');
    		$this->addElements(array($id,$service,$description,$enable,$envoyer));
     
    	}
    }
    mon controller :

    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
     
    public function ajouterserviceAction()
        {
            // action body
    		Zend_Layout::getMvcInstance()->setLayout('layoutajoutserv');
     
    		$form = new Application_Form_Ajoutservice();
    		$form->setAction('http://6.0.0.40/WebMRL/public/index.php/configuration/consulterunservice')
                 ->setMethod('post');
    		$form->envoyer->setLabel('Ajouter');
    		$this->view->form = $form;
    		if ($this->getRequest()->isPost()) {
    			$formData = $this->getRequest()->getPost();
    			if ($form->isValid($formData)) {
     
    				$service = $form->getValue('name');
    				$description = $form->getValue('link_description');
    				$enable = $form->getValue('enable');
     
    				$service = new Application_Model_DbTable_Service();
    				$service->ajouterService($service,$description,$enable);
    				$this->_redirect('/');
    			} else {
    				$form->populate($formData);
    			}
    		}
     
     
        }
    mon model :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    public function ajouterService($service,$description,$enable)
    	{
    			$data = array(
    			'name' => $service,
    			'link_description' => $description,
    			'enable' => $enable,
    			);
     
    			$this->insert($data);
     
    	}
    merci d'avance de votre aide.

    Cordialement,

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. enregistrer un chemin dans une BDD MySQL
    Par Sargon dans le forum C#
    Réponses: 11
    Dernier message: 23/08/2007, 11h59
  2. Réponses: 9
    Dernier message: 02/06/2007, 15h42
  3. Chemin BDD Firebird
    Par akli_agha dans le forum Bases de données
    Réponses: 3
    Dernier message: 28/04/2007, 08h41
  4. Réponses: 3
    Dernier message: 31/05/2006, 11h43
  5. Récupérer le chemin du fichier d'une bdd
    Par [DreaMs] dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 24/04/2006, 16h58

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