Marcel
Am 30.04.2009 um 12:10 schrieb Viktor Grandgeorg:
> your $config array is missing the primaryAssignment option. You must
> specify this as the default value is 'sessionId' for the
> primary key value and not 'session_id' as in your case. - Have a
> look at the constructor's API documentation in
> Zend/Session/SaveHandler/DbTable.php
>
> Or you modify your dbtable. For me the following works fine:
>
> BEGIN TRANSACTION;
> CREATE TABLE session (sessionId TEXT, sessionName TEXT,
> sessionSavePath TEXT, modified TEXT, data TEXT, lifetime TEXT);
> COMMIT;
>
> Then you can have the $config as follows:
>
> $config = array(
> 'name' => 'session',
> 'primary' => 'sessionId',
> 'modifiedColumn' => 'modified',
> 'dataColumn' => 'data',
> 'lifetimeColumn' => 'lifetime'
> );
>
>
> Have fun
> Viktor
>
>
>> -----Original Message-----
>> From: Marcel Alburg [mailto:m.alburg@weeaar.com]
>> Sent: Tuesday, April 28, 2009 11:37 PM
>> To: fw-mvc@lists.zend.com
>> Subject: [fw-mvc] Zend_Session with Sqlite DbTable not working
>>
>> Hello List,
>>
>> i've a problem if i use Zend_Session with
>> Zend_Session_SaveHandler_DbTable.
>>
>> I've i use the Zend_DB functions, it's not possible to store the
>> sessiondata into the Sqllite DB.
>>
>> I use a normal script without Zend
>>
>> ----
>> $dbh = new PDO('sqlite2:foo.sqlite3');
>>
>> $stmt = $dbh->prepare('INSERT INTO "session" ("session_id",
>> "modified", "session_data", "lifetime") VALUES (?, ?, ?, ?)');
>>
>> if (!$stmt) {
>> echo "\nPDO::errorInfo():\n";
>> print_r($dbh->errorInfo());
>> exit;
>> }
>>
>>
>> $aData = array(
>> '893ac6d16bdfce75018cd7f4bd8cc165',
>> 1240951239,
>> '',
>> 1440
>> );
>>
>> $stmt->execute($aData);
>> ---
>>
>> Works fine.
>>
>> But if i use Zend i get an exception.
>>
>>
>>
>> My Script:
>>
>> -----
>>
>> function exception_handler($e)
>> {
>> print $e->getMessage();
>> exit;
>> }
>>
>> require_once 'Zend/Loader.php';
>>
>> Zend_Loader::registerAutoload('Zend_Loader_Autoloader');
>>
>>
>> $db = Zend_Db::factory('Pdo_Sqlite', array(
>> 'username' => '',
>> 'password' => '',
>> 'dbname' => 'session.sqlite3',
>> 'sqlite2' => '1'
>> ));
>>
>> Zend_Db_Table_Abstract::setDefaultAdapter($db);
>>
>> $config = array(
>> 'name' => 'session',
>> 'primary' => 'session_id',
>> 'modifiedColumn' => 'modified',
>> 'dataColumn' => 'session_data',
>> 'lifetimeColumn' => 'lifetime'
>> );
>>
>>
>> Zend_Session::setSaveHandler(new
>> Zend_Session_SaveHandler_DbTable($config));
>>
>> // Session starten
>> Zend_Session::start();
>> ---
>>
>> gets the Exception:
>>
>> ---
>> SQLSTATE[HY000]: General error: 1 SQL logic error or missing
>> database<hr>EXCEPTION:<br><hr>[Message] => SQLSTATE[HY000]: General
>> error: 1 SQL logic error or missing database<br>[File] => /var/www/
>> tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/Db/S
>> tatement/
>> Pdo.php<br>[Line] => 238<br>[Trace] => <br>#0
>> /var/www/tracking/trunk/
>> library/ZendFramework-1.8.0b1/library/Zend/Db/Statement.php(283):
>> Zend_Db_Statement_Pdo->_execute(Array)
>> #1
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Adapter/Abstract.php(467): Zend_Db_Statement->execute(Array)
>> #2
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Adapter/Pdo/Abstract.php(235): Zend_Db_Adapter_Abstract-
>>> query('DELETE FROM "se...', Array)
>> #3
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Adapter/Abstract.php(632): Zend_Db_Adapter_Pdo_Abstract-
>>> query('DELETE FROM "se...')
>> #4
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Table/Abstract.php(1064): Zend_Db_Adapter_Abstract-
>>> delete('session', Array)
>> #5
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Session/SaveHandler/DbTable.php(380): Zend_Db_Table_Abstract-
>>> delete(Array)
>> #6
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Session/SaveHandler/DbTable.php(322):
>> Zend_Session_SaveHandler_DbTable-
>>> destroy('893ac6d16bdfce7...')
>> #7 [internal function]: Zend_Session_SaveHandler_DbTable-
>>> read('893ac6d16bdfce7...')
>> #8
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Session.php(438): session_start()
>> #9 /var/www/tracking/trunk/framwork/_projects_/Kunba/classes/
>> Controller/Abstract.php(14): Zend_Session::start()
>> #10
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Controller/Action.php(132): Kunba_Controller_Abstract->init()
>> #11
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Controller/Dispatcher/Standard.php(261): Zend_Controller_Action-
>>> __construct(Object(Zend_Controller_Request_Http),
>> Object(Zend_Controller_Response_Http), Array)
>> #12
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Controller/Front.php(936): Zend_Controller_Dispatcher_Standard-
>>> dispatch(Object(Zend_Controller_Request_Http),
>> Object(Zend_Controller_Response_Http))
>> #13 /var/www/tracking/trunk/framwork/_projects_/Kunba/
>> Bootstrap.php(436): Zend_Controller_Front->dispatch()
>> #14
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Application.php(302): Kunba_Bootstrap->run()
>> #15 /var/www/tracking/trunk/framwork/index.php(149):
>> Zend_Application-
>>> run()
>> #16 {main}<br>[GET] => Array
>> (
>> )
>> <br>[POST] => Array
>> (
>> )
>> <br>Zend_Db_Statement_Exception Object
>> (
>> [message:protected] => SQLSTATE[HY000]: General error: 1 SQL
>> logic error or missing database
>> [string:private] =>
>> [code:protected] => 0
>> [file:protected] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Statement/Pdo.php
>> [line:protected] => 238
>> [trace:private] => Array
>> (
>> [0] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Statement.php
>> [line] => 283
>> [function] => _execute
>> [class] => Zend_Db_Statement_Pdo
>> [type] => ->
>> [args] => Array
>> (
>> [0] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> [1] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Abstract.php
>> [line] => 467
>> [function] => execute
>> [class] => Zend_Db_Statement
>> [type] => ->
>> [args] => Array
>> (
>> [0] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> [2] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Pdo/Abstract.php
>> [line] => 235
>> [function] => query
>> [class] => Zend_Db_Adapter_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => DELETE FROM "session" WHERE
>> ("session_id" = '893ac6d16bdfce75018cd7f4bd8cc165')
>> [1] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> [3] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Abstract.php
>> [line] => 632
>> [function] => query
>> [class] => Zend_Db_Adapter_Pdo_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => DELETE FROM "session" WHERE
>> ("session_id" = '893ac6d16bdfce75018cd7f4bd8cc165')
>> )
>>
>> )
>>
>> [4] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Table/Abstract.php
>> [line] => 1064
>> [function] => delete
>> [class] => Zend_Db_Adapter_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => session
>> [1] => Array
>> (
>> [0] => "session_id" =
>> '893ac6d16bdfce75018cd7f4bd8cc165'
>> )
>>
>> )
>>
>> )
>>
>> [5] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Session/SaveHandler/DbTable.php
>> [line] => 380
>> [function] => delete
>> [class] => Zend_Db_Table_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => Array
>> (
>> [0] => "session_id" =
>> '893ac6d16bdfce75018cd7f4bd8cc165'
>> )
>>
>> )
>>
>> )
>>
>> [6] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Session/SaveHandler/DbTable.php
>> [line] => 322
>> [function] => destroy
>> [class] => Zend_Session_SaveHandler_DbTable
>> [type] => ->
>> [args] => Array
>> (
>> [0] => 893ac6d16bdfce75018cd7f4bd8cc165
>> )
>>
>> )
>>
>> [7] => Array
>> (
>> [function] => read
>> [class] => Zend_Session_SaveHandler_DbTable
>> [type] => ->
>> [args] => Array
>> (
>> [0] => 893ac6d16bdfce75018cd7f4bd8cc165
>> )
>>
>> )
>>
>> [8] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Session.php
>> [line] => 438
>> [function] => session_start
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [9] => Array
>> (
>> [file] => /var/www/tracking/trunk/framwork/
>> _projects_/Kunba/classes/Controller/Abstract.php
>> [line] => 14
>> [function] => start
>> [class] => Zend_Session
>> [type] => ::
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [10] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Controller/Action.php
>> [line] => 132
>> [function] => init
>> [class] => Kunba_Controller_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [11] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Controller/Dispatcher/Standard.php
>> [line] => 261
>> [function] => __construct
>> [class] => Zend_Controller_Action
>> [type] => ->
>> [args] => Array
>> (
>> [0] =>
>> Zend_Controller_Request_Http Object
>> (
>>
>> [_paramSources:protected] => Array
>> (
>> [0] => _GET
>> [1] => _POST
>> )
>>
>> [_requestUri:protected] => /
>> [_baseUrl:protected] =>
>> [_basePath:protected] =>
>> [_pathInfo:protected] => /
>> [_params:protected] => Array
>> (
>> [controller] => index
>> [action] => index
>> [module] => Kunba
>> )
>>
>> [_aliases:protected] => Array
>> (
>> )
>>
>> [_dispatched:protected] => 1
>> [_module:protected] => Kunba
>> [_moduleKey:protected] => module
>> [_controller:protected] => index
>> [_controllerKey:protected] =>
>> controller
>> [_action:protected] => index
>> [_actionKey:protected] => action
>> )
>>
>> [1] =>
>> Zend_Controller_Response_Http Object
>> (
>> [_body:protected] => Array
>> (
>> )
>>
>> [_exceptions:protected] => Array
>> (
>> )
>>
>> [_headers:protected] => Array
>> (
>> )
>>
>> [_headersRaw:protected] => Array
>> (
>> )
>>
>>
>> [_httpResponseCode:protected] =>
>> 200
>> [_isRedirect:protected] =>
>> [_renderExceptions:protected] =>
>> [headersSentThrowsException] => 1
>> )
>>
>> [2] => Array
>> (
>> [prefixDefaultModule] => 1
>> )
>>
>> )
>>
>> )
>>
>> [12] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Controller/Front.php
>> [line] => 936
>> [function] => dispatch
>> [class] => Zend_Controller_Dispatcher_Standard
>> [type] => ->
>> [args] => Array
>> (
>> [0] =>
>> Zend_Controller_Request_Http Object
>> (
>>
>> [_paramSources:protected] => Array
>> (
>> [0] => _GET
>> [1] => _POST
>> )
>>
>> [_requestUri:protected] => /
>> [_baseUrl:protected] =>
>> [_basePath:protected] =>
>> [_pathInfo:protected] => /
>> [_params:protected] => Array
>> (
>> [controller] => index
>> [action] => index
>> [module] => Kunba
>> )
>>
>> [_aliases:protected] => Array
>> (
>> )
>>
>> [_dispatched:protected] => 1
>> [_module:protected] => Kunba
>> [_moduleKey:protected] => module
>> [_controller:protected] => index
>> [_controllerKey:protected] =>
>> controller
>> [_action:protected] => index
>> [_actionKey:protected] => action
>> )
>>
>> [1] =>
>> Zend_Controller_Response_Http Object
>> (
>> [_body:protected] => Array
>> (
>> )
>>
>> [_exceptions:protected] => Array
>> (
>> )
>>
>> [_headers:protected] => Array
>> (
>> )
>>
>> [_headersRaw:protected] => Array
>> (
>> )
>>
>>
>> [_httpResponseCode:protected] =>
>> 200
>> [_isRedirect:protected] =>
>> [_renderExceptions:protected] =>
>> [headersSentThrowsException] => 1
>> )
>>
>> )
>>
>> )
>>
>> [13] => Array
>> (
>> [file] => /var/www/tracking/trunk/framwork/
>> _projects_/Kunba/Bootstrap.php
>> [line] => 436
>> [function] => dispatch
>> [class] => Zend_Controller_Front
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [14] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Application.php
>> [line] => 302
>> [function] => run
>> [class] => Kunba_Bootstrap
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [15] => Array
>> (
>> [file] => /var/www/tracking/trunk/framwork/
>> index.php
>> [line] => 149
>> [function] => run
>> [class] => Zend_Application
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> )
>> --
>>
>>
>> Thanks a lot
>>
>> Marcel Alburg
>>
>
>
没有评论:
发表评论