Groups > DB2 > DB2 on AS400 server > Zend_Db::factory with Db2




Zend_Db::factory with Db2

Zend_Db::factory with Db2
Tue, 11 Dec 2007 09:23:40 EST
Not sure if I'm posting this in the wrong place, but it pertains to Db2.  I've
also posted my question in the Zend developer zone forums, but nobody has
responded.  I'm trying to use Zend_Db's factory method to obtain a connection to
my iSeries, but I keep getting a Zend_Db_Adapter_Db2_Exception with the message
"The IBM DB2 extension is required for this adapter but the extension is
not loaded."<br />
<br />
When I installed and configured PHP, I selected just 4 extensions, ibm_db2, pdo,
pdo_ibm and pdo_odbc.  I don't get any errors when restarting Apache either.  It
seems to fail as soon as I call the getConnection() method.  Heres is a sample
of my code:<br />
<br />
public function ibmDb2Action() {<br />
    try {<br />
       $params = array (<br />
            'host'                =&gt; '192.168.xxx.xxx',<br />
            'username'     =&gt; 'myuser',<br />
            'password'     =&gt; 'mypass',<br />
            'dbname'         =&gt; 'mydbname'<br />
       );<br />
<br />
        $db = Zend_Db::factory ( 'Db2', $params );<br />
<br />
       echo "Getting connection...&lt;br /&gt;\n";<br
/>
        $db-&gt;getConnection();<br />
<br />
        echo "Closing connection...&lt;br /&gt;\n";<br
/>
        $db-&gt;closeConnection();<br />
<br />
    } catch ( Zend_Db_Adapter_Exception $e ) {<br />
        echo get_class ( $e ) . "&lt;br /&gt;\n";<br />
        echo $e-&gt;getMessage() . "&lt;br/&gt;\n";<br
/>
<br />
    } catch ( Zend_Exception $e ) {<br />
        echo get_class ( $e ) . "&lt;br /&gt;\n";<br />
        echo $e-&gt;getMessage() . "&lt;br /&gt;\n";<br
/>
    }<br />
Post Reply
about | contact