那是我的local.php配置:
'db' => array(
'driver' => 'pdo_mysql',
'dns' => 'mysql:dbname=xxxx;host=localhost;',
'username' => 'xxxx',
'password' => 'xxxx',
'port' => 3306,
'charset' => 'UTF8',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
)
)
这是我的身份验证码:
$authAdapter = new AuthAdapter($sm->get('Zend\Db\Adapter\Adapter'));
$authAdapter->setTableName('users')
->setIdentityColumn('username')
->setCredentialColumn('password')
->setCredentialTreatment("SHA2(CONCAT({$salt}, ?, salt), '512') AND active = 1");
$authAdapter->setIdentity($formData['username'])
->setCredential($formData['username']);
但是当我尝试提交登录表单时,zend框架会抛出这个错误:
文件:/var/www/app/vendor/zendframework/zend-authentication/src/Adapter/DbTable/AbstractAdapter.php:331
消息:提供给DbTable的参数无法生成有效的sql语句,请检查表和列名称的有效性。文件:/var/www/html/bookingSystemRewrite/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:244
消息:无法执行语句(3D000 - 1046 - 未选择数据库)文件:/var/www/html/bookingSystemRewrite/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:239
消息:SQLSTATE [3D000]:无效的目录名称:1046未选择数据库
答案 0 :(得分:0)
当我调试Pdo驱动程序适配器时,我发现我的问题在哪里。
第一个问题是按顺序:
Hash: d9f2eead3307d16f76f3
Version: webpack 1.12.8
Time: 350ms
+ 1 hidden modules
ERROR in ./src/index.jsx
Module build failed: SyntaxError: /Users/matiit/Documents/Private/Projects/color-game/src/index.jsx: Unexpected token (8:2)
6 |
7 | render(
> 8 | <ColorObj backgroundColor="green" textColor="black" />,
| ^
9 | rootElement
10 | );
11 |
必须如此:
'dns' => 'mysql:dbname=xxxx;host=localhost;'
第二个问题是按顺序:
'dsn' => 'mysql:dbname=xxxx;host=localhost;'
必须如此:
->setCredentialTreatment("SHA2(CONCAT({$salt}, ?, salt), '512') AND active = 1");