DbalSessionHandlerSchema.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bridge\Doctrine\HttpFoundation;
  11. use Doctrine\DBAL\Schema\Schema;
  12. /**
  13. * DBAL Session Storage Schema.
  14. *
  15. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  16. */
  17. final class DbalSessionHandlerSchema extends Schema
  18. {
  19. public function __construct($tableName = 'sessions')
  20. {
  21. parent::__construct();
  22. $this->addSessionTable($tableName);
  23. }
  24. public function addToSchema(Schema $schema)
  25. {
  26. foreach ($this->getTables() as $table) {
  27. $schema->_addTable($table);
  28. }
  29. }
  30. private function addSessionTable($tableName)
  31. {
  32. $table = $this->createTable($tableName);
  33. $table->addColumn('sess_id', 'string');
  34. $table->addColumn('sess_data', 'text')->setNotNull(true);
  35. $table->addColumn('sess_time', 'integer')->setNotNull(true)->setUnsigned(true);
  36. $table->setPrimaryKey(array('sess_id'));
  37. }
  38. }