Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 29-12-2010 15:55:27

matdev
Membre
Date d'inscription: 31-03-2009
Messages: 172

[résolu]PHP5.3 ZendServer et MsSQL

Bonjour à tous,

celà fait un petit moment que je ne suis pas passé sur le forum mais je vais soliciter votre aide pour quelques petites questions dues à une migration vers PHP5.3

Voilà je tavailler encore sous PHP5.2 mais depuis peu je rencontre des coupures d'Apache sur mon serveur de production et visiblement d'après tous les forums que j'ai parcourrus la solution est de passer à PHP5.3.


J'en profite pour tester en local le ZendServerCE avec PHP5.3.3 et ZendFramework1.11.1.
Problème dans beaucoup de mes applications je travaillais avec des bases mssql qui visiblement ne sont plus accessibles et je me retrouve avec l'erreur suivante :

Code:

An error occurred
Erreur dans l'application
Exception information:
Message: The mssql driver is not currently installed

Stack trace:
#0 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Adapter\Pdo\Mssql.php(137): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Adapter\Abstract.php(448): Zend_Db_Adapter_Pdo_Mssql->_connect()
#2 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('exec sp_columns...', Array)
#3 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Adapter\Pdo\Mssql.php(237): Zend_Db_Adapter_Pdo_Abstract->query('exec sp_columns...')
#4 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(823): Zend_Db_Adapter_Pdo_Mssql->describeTable('TBL_PORTS', NULL)
#5 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(845): Zend_Db_Table_Abstract->_setupMetadata()
#6 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(885): Zend_Db_Table_Abstract->_getCols()
#7 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(969): Zend_Db_Table_Abstract->_setupPrimaryKey()
#8 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Select.php(100): Zend_Db_Table_Abstract->info()
#9 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Select.php(78): Zend_Db_Table_Select->setTable(Object(Tblports))
#10 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(1005): Zend_Db_Table_Select->__construct(Object(Tblports))
#11 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(1303): Zend_Db_Table_Abstract->select()
#12 C:\Zend\Apache2\htdocs\consultdsp\application\controllers\BateauController.php(45): Zend_Db_Table_Abstract->fetchAll(NULL, 'po_id')
#13 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Controller\Action.php(513): BateauController->portAction()
#14 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('portAction')
#15 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#16 C:\Zend\Apache2\htdocs\consultdsp\index.php(44): Zend_Controller_Front->dispatch()
#17 {main}Request Parameters:
array(3) {
  ["controller"]=>
  string(6) "Bateau"
  ["action"]=>
  string(4) "port"
  ["module"]=>
  string(7) "default"
}

Pourriez-vous m'aider ???

Dernière modification par matdev (06-01-2011 08:52:26)

Hors ligne

 

#2 29-12-2010 22:05:58

mikaelkael
Administrateur
Lieu: Donges
Date d'inscription: 18-06-2007
Messages: 1176
Site web

Re: [résolu]PHP5.3 ZendServer et MsSQL

Hello,

Sous Windows, de mémoire tu dois utiliser l'adapter Sqlsrv.

@+


Less code = less bugs
Contributeur ZF - ZCE - ZFCE - Doc ZF (CHM & PDF) - Vice-trésorier AFUP 2011
Ubuntu 11.04 - ZendServer

Hors ligne

 

#3 30-12-2010 09:04:36

matdev
Membre
Date d'inscription: 31-03-2009
Messages: 172

Re: [résolu]PHP5.3 ZendServer et MsSQL

Merci mikaelkael,
en effet j'ai vu que la dll sqlsrv était présente dans ZendServer et je suis donc partis sur ce sujet. J'ai du installé un client natif sql server 2008 pour qu'il fonctionne mais je me retrouve maintenant avec le problème suivant :

Code:

Exception information:
Message: The connection cannot process this operation because there is a statement with pending results. To make the connection available for other queries, either fetch all results or cancel or free the statement. For more information, see the product documentation about the MultipleActiveResultSets connection option.

Stack trace:
#0 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Statement.php(300): Zend_Db_Statement_Sqlsrv->_execute(Array)
#1 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Adapter\Abstract.php(468): Zend_Db_Statement->execute(Array)
#2 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Adapter\Sqlsrv.php(458): Zend_Db_Adapter_Abstract->query('exec sp_pkeys @...')
#3 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(823): Zend_Db_Adapter_Sqlsrv->describeTable('TBL_ACHETEUR', NULL)
#4 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(845): Zend_Db_Table_Abstract->_setupMetadata()
#5 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(885): Zend_Db_Table_Abstract->_getCols()
#6 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(969): Zend_Db_Table_Abstract->_setupPrimaryKey()
#7 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Select.php(100): Zend_Db_Table_Abstract->info()
#8 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Select.php(78): Zend_Db_Table_Select->setTable(Object(Tblacheteur))
#9 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(1005): Zend_Db_Table_Select->__construct(Object(Tblacheteur))
#10 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Db\Table\Abstract.php(1303): Zend_Db_Table_Abstract->select()
#11 C:\Zend\Apache2\htdocs\consultdsp\application\controllers\ClientController.php(82): Zend_Db_Table_Abstract->fetchAll('1=1', Array)
#12 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Controller\Action.php(513): ClientController->acheteurAction()
#13 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('acheteurAction')
#14 C:\Zend\Apache2\htdocs\consultdsp\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#15 C:\Zend\Apache2\htdocs\consultdsp\index.php(44): Zend_Controller_Front->dispatch()
#16 {main}

Voici ma fonction dans mon controleur

Code:

public function acheteurAction(){
        $this->view->title=utf8_encode("Liste des acheteurs");

                $montri="";
        if ($this->_getParam('tri')!=null) {
            $montri=$this->_getParam('tri');
            if($montri=="ac_type"){
                $tri=array("ac_type","ac_entite","ac_nom");
                $listetri=array("ac_type","ac_entite","ac_nom");
            }
            if($montri=="ac_entite"){
                $tri=array("ac_entite","ac_nom");
                $listetri=array("ac_entite","ac_nom");
            }
            if($montri=="ac_nom"){
                $tri="ac_nom";
                $listetri="ac_nom";
            }
        }else{
            $tri=array("ac_type","ac_entite","ac_nom");
            $listetri=array("ac_type","ac_entite","ac_nom");
        }
        if ($this->_getParam('filtre')!=null && $this->_getParam('filtre')!="" ) {
            $where="ac_type=".$this->_getParam('filtre')." ";
            $filtre=$this->_getParam('filtre');
        }else{
            $where="1=1";
            $filtre="";
        }
        if ($this->_getParam('filtre2')!=null && $this->_getParam('filtre2')!="" ) {
            if($this->_getParam('filtre2')==0)
            $where2=" and ac_date_fermeture IS NULL";
            if($this->_getParam('filtre2')==1)
            $where2=" and ac_date_fermeture IS NOT NULL";
            $filtre2=$this->_getParam('filtre2');
        }else{
            $where2="";
            $filtre2="";
        }

                $dbmssql = Zend_Registry::get('dbmssql');

                $requete2 = $dbmssql->query('SELECT distinct(ac_type), ta_nom FROM dbo.TBL_ACHETEUR WITH(NOLOCK) INNER JOIN dbo.TBL_TYPE_ACHETEUR WITH(NOLOCK) ON ac_type=ta_code ORDER BY ta_nom;');
        $resultat2=$requete2->fetchAll();
        $this->view->types=$resultat2;

        $requete3 = $dbmssql->query('SELECT distinct(ac_entite)FROM dbo.TBL_ACHETEUR WITH(NOLOCK);');
        $resultat3=$requete3->fetchAll();
        $this->view->entites=$resultat3;

        $this->view->tri=$montri;
        $this->view->filtre=$filtre;
        $this->view->filtre2=$filtre2;

                $acheteurs=new Tblacheteur();
                $acheteurs=$acheteurs->fetchAll($where.$where2,$listetri);
                $page = Zend_Paginator::factory($acheteurs);
        $page->setPageRange(5);
        $page->setCurrentPageNumber($this->_getParam('page', 1));
        $page->setItemCountPerPage($this->_getParam('par', 25));
        $this->view->acheteurs = $page;

        $this->render();
        }

sachant que la ligne 82 est la suivante :

Code:

 $acheteurs=$acheteurs->fetchAll($where.$where2,$listetri);

Voici également la configuration utilisée pour la connection

Code:

database2.adapter = SQLSRV
database2.params.host = "X.X.X.X"
database2.params.username = "analyse"
database2.params.password = "analyse"
database2.params.dbname = TBLCRIEEBOU

évidemment l'ip de l'hote est ok

Quelqu'un aurait une idée ?

Dernière modification par matdev (30-12-2010 09:25:43)

Hors ligne

 

#4 30-12-2010 14:24:19

matdev
Membre
Date d'inscription: 31-03-2009
Messages: 172

Re: [résolu]PHP5.3 ZendServer et MsSQL

Bon j'avance un peu dans ma recherche de solution.
Au lieu d'utiliser mon modele Tblacheteur, j'ai écrit directement la requête avec "select * from TblAcheteur ..."
et là mon mssql s'execute bien sauf que je n'ai plus d'objet à rentrer dans ma pagination.

J'ai un peu de mal à comprendre pourquoi ceci fonctionne :

Code:

$dbmssql = Zend_Registry::get('dbmssql');

$requete2 = $dbmssql->query('SELECT distinct(ac_type), ta_nom FROM dbo.TBL_ACHETEUR WITH(NOLOCK) INNER JOIN dbo.TBL_TYPE_ACHETEUR WITH(NOLOCK) ON ac_type=ta_code ORDER BY ta_nom;');
$resultat2=$requete2->fetchAll();
$this->view->types=$resultat2;

$requete3 = $dbmssql->query('SELECT distinct(ac_entite)FROM dbo.TBL_ACHETEUR WITH(NOLOCK);');
$resultat3=$requete3->fetchAll();
$this->view->entites=$resultat3;

Mais pas ça :

Code:

$acheteurs=new Tblacheteur();
$acheteurs=$acheteurs->fetchAll($where.$where2,$listetri);

Dernière modification par matdev (30-12-2010 14:32:10)

Hors ligne

 

#5 06-01-2011 08:52:07

matdev
Membre
Date d'inscription: 31-03-2009
Messages: 172

Re: [résolu]PHP5.3 ZendServer et MsSQL

Bon au final j'ai adapté mon code pour ne plus utiliser les objets. Je passe par des requêtes directes et envoie mon tableau de résultat à la pagination. Peut-être une solution de simplicité (ou pas ....) mais au moins ça fonctionne.

Merci à ceux qui cherche une solution

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages