Ejemplo n.º 1
0
 /**
  * Destroy session
  *
  * @param  string $id
  * @return bool
  */
 public function destroy($id)
 {
     if (!(bool) $this->read($id, false)) {
         return true;
     }
     return (bool) $this->tableGateway->delete([$this->options->getIdColumn() => $id, $this->options->getNameColumn() => $this->sessionName]);
 }
Ejemplo n.º 2
0
 /**
  * Destroy session
  *
  * @param string $id
  * @return boolean
  */
 public function destroy($id)
 {
     return (bool) $this->tableGateway->delete(array(
         $this->options->getIdColumn() => $id,
         $this->options->getNameColumn() => $this->sessionName,
     ));
 }
 public function testSetters()
 {
     $options = new DbTableGatewayOptions();
     $options->setIdColumn('testId')->setNameColumn('testName')->setModifiedColumn('testModified')->setLifetimeColumn('testLifetime')->setDataColumn('testData');
     $this->assertEquals('testId', $options->getIdColumn());
     $this->assertEquals('testName', $options->getNameColumn());
     $this->assertEquals('testModified', $options->getModifiedColumn());
     $this->assertEquals('testLifetime', $options->getLifetimeColumn());
     $this->assertEquals('testData', $options->getDataColumn());
 }
    /**
     * Sets up the database connection and creates the table for session data
     *
     * @param  Zend\Session\SaveHandler\DbTableGatewayOptions $options
     * @return void
     */
    protected function setupDb(DbTableGatewayOptions $options)
    {
        $this->adapter = new Adapter(array(
            'driver' => 'pdo_sqlite',
            'database' => ':memory:',
        ));


        $query = <<<EOD
CREATE TABLE `sessions` (
    `{$options->getIdColumn()}` text NOT NULL,
    `{$options->getNameColumn()}` text NOT NULL,
    `{$options->getModifiedColumn()}` int(11) default NULL,
    `{$options->getLifetimeColumn()}` int(11) default NULL,
    `{$options->getDataColumn()}` text,
    PRIMARY KEY (`{$options->getIdColumn()}`, `{$options->getNameColumn()}`)
);
EOD;
        $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
        $this->tableGateway = new TableGateway('sessions', $this->adapter);
    }