If you checked my last post, you will have read about how to get all your old ZF1 classes autoloading in your new shiny ZF2 project. However, the DB settings from your application.ini won’t have been set, and so you’ll get a 500 response with No Db Adapter. Not a problem. We just create the db adapter ourselves and tell Zend_Db that it is the default.
I’ve put this in the ZF2 index.php just before the last line, Zend\Mvc\Application::init($appConfig)->run();
//Set up ZF1 DB $params = array( 'host' => '127.0.0.1', 'username' => 'xxx', 'password' => 'xxx', 'dbname' => 'xxx' ); $adapter = Zend_Db::factory('Pdo_Mysql',$params); Zend_Db_Table_Abstract::setDefaultAdapter($adapter);
Now your autoloading ZF1 DB classes wont freak out, and should connect no problem!