Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework > Autres composants
Autres composants Forum de support sur les autres composants de Zend Framework.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 04/05/2011, 16h47   #1
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
Par défaut Intégration Doctrine dans Zend

Bonjour, je suis en train de suivre le tutoriel de Thorin19 ici :

http://www.throrinstudio.com/blog/in...e/idarticle/51

Seulement lorsque je lance "php Doctrine.php"

Je me retrouve toujours avec cette erreur

Code :
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
c:\wamp\www\tutosite.com\application\scripts>php Doctrine.php
 
PHP Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with messag
e 'There is no open connection' in C:\wamp\www\tutosite.com\library\Doctrine\Man
ager.php:662
Stack trace:
#0 C:\wamp\www\tutosite.com\library\Doctrine\Manager.php(264): Doctrine_Manager-
>getCurrentConnection()
#1 C:\wamp\www\tutosite.com\application\Bootstrap.php(98): Doctrine_Manager::con
nection(NULL, 'doctrine')
#2 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract
.php(667): Bootstrap->_initDoctrine()
#3 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract
.php(627): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('doctr
ine')
#4 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract
.php(584): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap('doctrine')
#5 C:\wamp\www\tutosite.com\application\scripts\Doctrine.php(31): Zend_Applicati
on_Bootstrap_BootstrapAbstract->bootstrap('doctrine')
#6 {main}
thrown in C:\wamp\www\tutosite.com\library\Doctrine\Manager.php on line 662
 
Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with message 'Th
ere is no open connection' in C:\wamp\www\tutosite.com\library\Doctrine\Manager.
php:662
Stack trace:
#0 C:\wamp\www\tutosite.com\library\Doctrine\Manager.php(264): Doctrine_Manager-
>getCurrentConnection()
#1 C:\wamp\www\tutosite.com\application\Bootstrap.php(98): Doctrine_Manager::con
nection(NULL, 'doctrine')
#2 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract
.php(667): Bootstrap->_initDoctrine()
#3 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract
.php(627): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('doctr
ine')
#4 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract
.php(584): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap('doctrine')
#5 C:\wamp\www\tutosite.com\application\scripts\Doctrine.php(31): Zend_Applicati
on_Bootstrap_BootstrapAbstract->bootstrap('doctrine')
#6 {main}
thrown in C:\wamp\www\tutosite.com\library\Doctrine\Manager.php on line 662
J'ai bien déclaré :

Code :
1
2
3
4
5
6
7
protected static function _initNamespaces() 
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('App_');
$autoloader->registerNamespace('Doctrine_');
$autoloader->registerNamespace('Doctrine');	
}
dans le bootstrap.
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 16h51   #2
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
et le _initDoctrine() ?
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 16h56   #3
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
J'ai repris le même que dans l'exemple :

Code :
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
protected function _initDoctrine() 
	{
		//on met Doctrine en autoload
        $this->getApplication()
             ->getAutoloader()
             ->pushAutoloader ( array ('Doctrine', 'autoload' ) );
        spl_autoload_register(array('Doctrine', 'modelsAutoload'));
 
        //on récupère une instance de Doctrine
        $manager = Doctrine_Manager::getInstance ();
 
        //permet de valider automatiquement l'intégrité des données
        //ce qui veut dire que l'on ne peut pas mettre une variable de type string
        //dans une variable de type int.
        $manager->setAttribute (Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
        //l’AUTO_ACCESSOR_OVERRIDE va nous permettre de personnaliser l’assignation de données.
        $manager->setAttribute ( Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true );
        //Doctrine permet de personnaliser également les classes de table en permettant 
        //de créer des méthodes propres à une table. 
        //Ce paramètre permet de charger le fichier contenant nos méthodes personnalisées.
        $manager->setAttribute (
        	Doctrine::ATTR_MODEL_LOADING, 
        	Doctrine::MODEL_LOADING_CONSERVATIVE
        );
        //on permet le chargement des classes table
        $manager->setAttribute ( Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true );
 
        //on récupère toutes les options doctrine du fichier app.ini
        $doctrineConfig = $this->getOption('doctrine');
 
        //on récupère la variable doctrine.models_path du fichier app.ini
        //afin d'avoir le répertoire des models
        //pour que Doctrine les charge
        Doctrine::loadModels($doctrineConfig['models_path']);
 
        //on récupère la connexion à mysql et on la nomme doctrine
        $conn = Doctrine_Manager::connection($doctrineConfig['dsn'],'doctrine');
        //je sais plus ce que sa veut dire, mais il le faut
        $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM,true);
 
        //on définit la sortie encodée en UTF-8
        $conn->setCharset('utf8');
        $conn->setCollate('utf8_general_ci');
 
        //on retourne la connexion
        return $conn;
    }
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h02   #4
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
Normalement la classe unique Doctrine n'existe plus (est plutôt déprécié) il faut utilise Doctrine_Core a la place.
Est tu sur de ton DSN ? la il est sur NULL
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h07   #5
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
Est-ce que tu connais un bon tuto pour l'intégration de doctrine dans Zend, assez récent?

Si tu parles de cette ligne :

Code :
doctrine.dsn= "mysql://root@localhost/tutosite"
Je t'avoue que c'est la seule pour laquelle j'ai un doute :
Je n'ai pas de mot de passe, et mon nom d'utilisateur est "root"
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h10   #6
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
je disais plus ça dans le sens ou $doctrineConfig['dsn'] n'a pas l'air de renvoyer grand chose
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h17   #7
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
Yep, je suis d'accord. Mais je ne vois toujours pas d'où cela peut venir. Je vais essayer de changer deux trois configs, mais si une âme qui passe a la bonté e m'expliquer, je suis preneur.
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h25   #8
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
ton niveau d'erreur est bien au maximum ?, au pire regarde avec un var_dump ce que rend $doctrineConfig
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h30   #9
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
Elle contient bien "NULL"

Mon message d'erreur se situe en deux parties :

Code :
Notice: Undefined variable: doctrineConfig in C:\wamp\www\tutosite.com\application\modules\default\views\scripts\index\index.phtml on line 2
puis
Je ne sais pas s'il "est maximum" par contre.
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h42   #10
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
le var_dump met le direct dans le _initDoctrine pas dans la vue
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h51   #11
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
J'ai ça :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
array
  'dsn' => string 'mysql://root@localhost/tutosite' (length=31)
  'data_fixtures_path' => string 'C:\wamp\www\tutosite.com\application/configurations/data/fixtures' (length=65)
  'sql_path' => string 'C:\wamp\www\tutosite.com\application/configurations/data/sql' (length=60)
  'migrations_path' => string 'C:\wamp\www\tutosite.com\application/configurations/migrations' (length=62)
  'yaml_schema_path' => string 'C:\wamp\www\tutosite.com\application/configurations/schema.yml' (length=62)
  'models_path' => string 'C:\wamp\www\tutosite.com\application/../library/App/Models' (length=58)
  'generate_models_options' => 
    array
      'pearStyle' => string '1' (length=1)
      'generateTableClasses' => string '1' (length=1)
      'generateBaseClasses' => string '1' (length=1)
      'baseClassPrefix' => string 'Base_' (length=5)
      'baseClassesDirectory' => string '' (length=0)
      'classPrefixFiles' => string '' (length=0)
      'classPrefix' => string 'App_Models_' (length=11)
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 17h57   #12
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
étrange il est bien la, pourtant il rend NULL apres, essaye de le mettre en hard dans la méthode pour testé
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 18h53   #13
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
quelque chose du genre :
Code :
        $conn = Doctrine_Manager::connection($doctrineConfig['mysql://root@localhost/tutosite'],'doctrine');
Edit : voici l'erreur que ça génère. La même en fait, mais la voici en mieux indentée :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
PHP Fatal error:  Uncaught exception 'Doctrine_Connection_Exception' with message 'There is no open connection' in C:\wamp\www\tutosite.com\library\Doctrine\Manager.php:662
Stack trace:
#0 C:\wamp\www\tutosite.com\library\Doctrine\Manager.php(264): Doctrine_Manager->getCurrentConnection()
#1 C:\wamp\www\tutosite.com\application\Bootstrap.php(98): Doctrine_Manager::connection(NULL, 'doctrine')
#2 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract.php(667): Bootstrap->_initDoctrine()
#3 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract.php(627): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('doctrine')
#4 C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract.php(584): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap('doctrine')
#5 C:\wamp\www\tutosite.com\application\scripts\Doctrine.php(31): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap('doctrine')
#6 {main}
thrown in C:\wamp\www\tutosite.com\library\Doctrine\Manager.php on line 662
 
 Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with message 'There is no open connection' in C:\wamp\www\tutosite.com\library\Doctrine\Manager.php on line 662
Doctrine_Connection_Exception: There is no open connection in C:\wamp\www\tutosite.com\library\Doctrine\Manager.php on line 662
Call Stack:
 0.0007     641448   1. {main}() C:\wamp\www\tutosite.com\application\scripts\Doctrine.php:0
 0.0170    2124384   2. Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() C:\wamp\www\tutosite.com\application\scripts\Doctrine.php:31
 0.0170    2124384   3. Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap() C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract.php:584
 0.0170    2124384   4. Zend_Application_Bootstrap_BootstrapAbstract->_executeResource() C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract.php:627
 0.0172    2125896   5. Bootstrap->_initDoctrine() C:\wamp\www\tutosite.com\library\Zend\Application\Bootstrap\BootstrapAbstract.php:667
 0.0213    2542056   6. Doctrine_Manager::connection() C:\wamp\www\tutosite.com\application\Bootstrap.php:98
 0.0213    2542056   7. Doctrine_Manager->getCurrentConnection() C:\wamp\www\tutosite.com\library\Doctrine\Manager.php:264
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 19h22   #14
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
non plutôt

Code :
$conn = Doctrine_Manager::connection('mysql://root@localhost/tutosite','doctrine');
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 19h25   #15
Invité de passage
 
Inscription : novembre 2010
Messages : 35
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 35
Points : 2
Points : 2
L'erreur est un peu différente :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
C:\wamp\www\tutosite.com\application\scripts>php Doctrine.php
NULL
PHP Catchable fatal error:  Argument 1 passed to Doctrine_Cli::__construct() must be an array, null given, called in C:\wamp\www\tutosite.com\application\scripts\Doctrine.php on line 34 and defined in C:\wamp\www\tutosite.com\library\Doctrine\Cli.php on line 77
PHP Stack trace:
PHP   1. {main}() C:\wamp\www\tutosite.com\application\scripts\Doctrine.php:0
PHP   2. Doctrine_Cli->__construct() C:\wamp\www\tutosite.com\application\scripts\Doctrine.php:34
 
Catchable fatal error: Argument 1 passed to Doctrine_Cli::__construct() must be an array, null given, called in C:\wamp\www\tutosite.com\application\scripts\Doctrine.php on line 34 and defined in C:\wamp\www\tutosite.com\library\Doctrine\Cli.php on line 77
 
Call Stack:
  0.0007     641448   1. {main}() C:\wamp\www\tutosite.com\application\scripts\Doctrine.php:0
  0.0403    3728424   2. Doctrine_Cli->__construct() C:\wamp\www\tutosite.com\application\scripts\Doctrine.php:34
4

Si j'ai bien compris, il reste nul lors de l'appel au constructeur. Alors que sur ma page, j'ai bien
Code :
1
2
array
  'dsn' => string 'mysql://root@localhost/tutosite' (length=31)
Pourtant, lorsque je fais un "var_dump" de $conn, j'ai bien ça :

Code :
1
2
3
4
5
6
7
8
protected 'options' => 
    array
      'dsn' => string 'mysql:host=localhost;dbname=tutosite' (length=36)
      'username' => string 'root' (length=4)
      'password' => null
      'other' => 
        array
          empty
Kai231 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h47.


 
 
 
 
Partenaires

Hébergement Web