Thanks to all.

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();

Seems to work well.

Regards,
--
Louie Miranda
- Email: [email protected]
- Web: http://www.louiemiranda.com



On Tue, Jun 29, 2010 at 2:59 PM, Nilesh Govindarajan <[email protected]>wrote:

> On 06/29/2010 12:26 PM, Chris Riesen wrote:
>
>> 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
>>>
>>>
>>>
> This is the best. Autoloader. If you configure it, use ZF as you want, any
> class of ZF won't make such complaints :D
>
>
> --
> Regards,
> Nilesh Govindarajan
> Facebook: http://www.facebook.com/nilesh.gr
> Twitter: http://twitter.com/nileshgr
> Website: http://www.itech7.com
> Cheap and Reliable VPS Hosting: http://j.mp/arHk5e
>

Reply via email to