Hi Louie
Replace your "require_once 'Zend/Db.php';" line with these two:
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
And it will work. That way you can also autoload more than just the DB
components.
Alternatively, use the Factory method, by keeping all the code the
same ecept that one line where you get the $db object::
$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => '192.168.1.33',
'username' => 'dba',
'password' => 'pass',
'dbname' => 'database'
));
Personally, I prefer the autoloader, as it does away with all those
require_once calls.
- Chris
On Tue, Jun 29, 2010 at 8:50 AM, Louie Miranda <[email protected]> wrote:
> I am trying ZF as a loose class, but I am failing when connecting to a db.
>
> I have added the ZF library on php.ini includes and created a file.
>
> test01.php
>
> <?php
> require_once 'Zend/Db.php';
> $db = new Zend_Db_Adapter_Pdo_Mysql(array(
> 'host' => '192.168.1.33',
> 'username' => 'dba',
> 'password' => 'pass',
> 'dbname' => 'database'
> ));
>
> print_r($db);
> ?>
>
> The error is, PHP Fatal error: Class 'Zend_Db_Adapter_Pdo_Mysql' not found
>
> I believe Zend/Db.php is trying to look for the adapater inside the
> /test/test01.php directory? What should I do to correct this? and is this
> proper?
> --
> Louie Miranda
> - Email: [email protected]
> - Web: http://www.louiemiranda.com
>
>