我希望在zf2 module.php文件中的会话表中存储会话后获得自动增量ID
以下是我的代码:
$session_id = $sessionManager->getId();
现在我想要的是什么:
$session_table = $sm->get('session_table');
$resultset = $session_table->select(array(
'id' => $sessionManager->getId()
));
$row = $resultset->current();
$session_last_id = $row['session_id'];
在$session_last_id
中,我将获得特定会话ID的自动增量ID,
问题是:
创建会话时,我没有获得自动增量ID。我收到错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'session_id' cannot be null' in E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php:240 Stack trace: #0 E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php(240): PDOStatement->execute() #1 E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(291): Zend\Db\Adapter\Driver\Pdo\Statement->execute() #2 E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(258): Zend\Db\TableGateway\AbstractTableGateway->executeInsert(Object(Zend\Db\Sql\Insert)) #3 E:\xampp\htdocs\equatmedia_new\module\Equate\Module.php(52): Zend\Db\TableGateway\AbstractTableGateway->insert(Array) #4 [internal function]: Equate\Module->onBootstrap(Object(Zend\Mvc\MvcEvent)) #5 E:\xampp\h in E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php on line 245
但是一旦我刷新页面,错误就会消除,我会得到我想要的东西。 为什么我要刷新页面..?我希望id不刷新页面而且没有错误。
我需要帮助的朋友。 我们将非常感谢您的帮助。请帮帮我..