使用 ZF1,当我创建数据库连接字符串时,它可以正常工作。但是在 ZF2 数据库适配器中似乎 BUG 永远不会起作用,它总是给出以下内容:
错误:
[Fri Nov 02 13:26:25 2012] [error] [client 127.0.0.1] PHP Fatal error: Class 'Application\\Controller\\Zend\\Db\\Adapter\\Adapter' not found in /var/www/html/org/module/Application/src/Application/Controller/TestController.php on line 17
代码:
<?php
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Db\Adapter\Adapter;
//use Zend\Db\Adapter\Platform\PlatformInterface;
//use Zend\Db\ResultSet\ResultSet;
class TestController extends AbstractActionController {
public function indexAction() {
$driverArray = array(
'driver' => 'Pdo_Mysql',
'database' => 'web145',
'username' => 'web145',
'password' => 'meandmypassword',
'host'=>'localhost'
);
$adapter = new Zend\Db\Adapter\Adapter($driverArray);
//Zend\Db\Adapter\Adapter::query('SELECT * FROM `sh_operaor`');
//var_dump ($adapter->query('SELECT * FROM `sh_operaor`'));
exit;
}
}