DoctrineDbal.php.dist 817 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use Doctrine\DBAL\DriverManager;
  3. use Gaufrette\Adapter\DoctrineDbal;
  4. $connection = DriverManager::getConnection(array(
  5. 'driver' => 'pdo_sqlite',
  6. 'memory' => true,
  7. ));
  8. $platform = $connection->getDatabasePlatform();
  9. $schemaManager = $connection->getSchemaManager();
  10. if (in_array('gaufrette', $schemaManager->listTableNames())) {
  11. $schemaManager->dropTable('gaufrette');
  12. }
  13. $schema = $schemaManager->createSchema();
  14. $table = $schema->createTable('gaufrette');
  15. $table->addColumn('key', 'string', array('unique' => true));
  16. $table->addColumn('content', 'blob');
  17. $table->addColumn('mtime', 'integer');
  18. $table->addColumn('checksum', 'string', array('length' => 32));
  19. foreach ($schema->toSql($platform) as $query) {
  20. $connection->exec($query);
  21. }
  22. return new DoctrineDbal($connection, 'gaufrette');