I tested with schema too but i had the same result (on V5R3).
I tested with getConnection() too and the result is :
[28-jan-2009 18:33:37] PHP Fatal error: Uncaught exception
'Zend_Db_Adapter_Db2_Exception' with message 'Connexion à base de données
relationnelle S65EA94B déjà établie. SQLCODE=-842' in
/usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Db2.php:191
Stack trace:
#0
/usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Abstract.php(300
): Zend_Db_Adapter_Db2->_connect()
#1 /www/php/site/admin/public/testdb.php(15):
Zend_Db_Adapter_Abstract->getConnection()
#2 {main}
thrown in
/usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Db2.php on line
191
Same script works fine on V5R4.
David Ulrich
-----Message d'origine-----
De : Ralph Schindler [mailto:ralph.schindler@zend.com]
Envoyé : mercredi 28 janvier 2009 18:11
À : David Ulrich; fw-db@lists.zend.com
Objet : Re: [fw-db] Zend_Db_Adapter_DB2 on I5
>From the trace stack, it appears your connection is not being made
correctly.
Have you tried adding schema to your Zend_Db::factory()?
I imagine it would look like so:
$db = Zend_Db::factory('Db2',array(
'host'=>'127.0.0.1',
'username'=>'USERNAME',
'password'=>'password',
'dbname'=>'DATABASE',
'schema'=>'MYLIB'
));
And to test, you can simply ensure this works:
$db->getConnection(); // this should not fail.
sidenote: connections are lazy-loaded until the first usage, so while the
above is something good to test your connection; lazy-loading the connection
(which is what you are doing in your scripts utilizing the table) are a good
thing. Once you figure out why the connection is failing, remove the
getConnection() from your bootstrap. This will prevent requests that don't
use a db connection from actually connecting to the database.
On 1/28/09 7:45 AM, "David Ulrich" <david@dahuu.fr> wrote:
> Hi,
>
> I¹m trying to use Zend_Db on my I5 but I have some problems.
> I create a little test file and test it on 2 I5 (one V5R3 and one V5R4).
> I downloaded the latest svn trunk for testing.
>
> [code]
> <?php
> require_once "Zend/Loader.php";
> // Set up autoload.
> Zend_Loader::registerAutoload();
>
> class Alertes extends Zend_Db_Table_Abstract {
> /**
> * The default table name
> */
> protected $_name = 'MYFILE';
> protected $_schema = 'MYLIB';
> protected $_primary = 'MACLE';
> }
>
> $db = Zend_Db::factory('Db2',array(
> 'host'=>'127.0.0.1',
> 'username'=>'USERNAME',
> 'password'=>'password',
> 'dbname'=>'DATABASE'));
> Zend_Db_Table::setDefaultAdapter($db);
>
> // #1
> $sql = 'select * from MYLIB.MYFILE';
> print_r($db->fetchAll($sql));
>
> // #2
> $alertes = new Alertes();
> print_r($alertes->fetchAll());
> ?>
> [/code]
>
> On V5R3, nothing works. I got this message (as the message is in French,
> message is : Connection to database DATABASE already done) :
> [code]
> [28-Jan-2009 14:33:40] PHP Fatal error: Uncaught exception
> 'Zend_Db_Adapter_Db2_Exception' with message 'Connexion à base de données
> relationnelle DATABASE déjà établie. SQLCODE=-842' in
> /usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Db2.php:191
> Stack trace:
> #0
>
/usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Abstract.php(441
):
> Zend_Db_Adapter_Db2->_connect()
> #1
>
/usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Abstract.php(668
):
> Zend_Db_Adapter_Abstract->query('select * from M...', Array)
> #2 /www/php/site/admin/public/testdb.php(16):
> Zend_Db_Adapter_Abstract->fetchAll('select * from M...')
> #3 {main}
> thrown in
> /usr/local/Zend/ZendFramework-1.7.3/library/Zend/Db/Adapter/Db2.php on
line
> 191
> [/code]
>
> On V5R4, the #1 works fine but not #2 wich this message :
> [code]
> [28-Jan-2009 11:43:53] PHP Fatal error: Uncaught exception
> 'Zend_Db_Statement_Db2_Exception' with message 'Qualificatif de colonne ou
> table MYFILE non défini. SQLCODE=-5001' in
> /usr/local/Zend/ZendFramework-1.7/library/Zend/Db/Statement/Db2.php:71
> Stack trace:
> #0 /usr/local/Zend/ZendFramework-1.7/library/Zend/Db/Statement.php(109):
> Zend_Db_Statement_Db2->_prepare('select MYFILE...')
> #1 /usr/local/Zend/ZendFramework-1.7/library/Zend/Db/Adapter/Db2.php(230):
> Zend_Db_Statement->__construct(Object(Zend_Db_Adapter_Db2), 'select
> MYFILE...')
> #2
>
/usr/local/Zend/ZendFramework-1.7/library/Zend/Db/Adapter/Abstract.php(456):
> Zend_Db_Adapter_Db2->prepare('select MYFILE...')
> #3
>
/usr/local/Zend/ZendFramework-1.7/library/Zend/Db/Adapter/Abstract.php(668):
> Zend_Db_Adapter_Abstract->query('select MYFILE...', Array)
> #4 /www/alertes/public/testdb.php(23):
> Zend_Db_Adapter_Abstract->fetchAll('select MYFILE...')
> #5 {main}
> thrown in
> /usr/local/Zend/ZendFramework-1.7/library/Zend/Db/Statement/Db2.php on
line 71
> [/code]
> The sql generated by Zend_DB_Table does not work on I5.
>
> Did I miss something ?
>
> Thanks,
> David
>
--
Ralph Schindler
Software Engineer | ralph.schindler@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论