Last active
February 25, 2022 08:46
-
-
Save gbirke/c77b0cd0f07763787796c4b3799a85a6 to your computer and use it in GitHub Desktop.
Testing sequence support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"doctrine/dbal": "^3.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
mysql5: | |
image: mysql:5 | |
environment: | |
MYSQL_DATABASE: "seq_test" | |
MYSQL_USER: "test" | |
MYSQL_PASSWORD: "1234" | |
MYSQL_ROOT_PASSWORD: "toor" | |
mysql8: | |
image: mysql:8 | |
environment: | |
MYSQL_DATABASE: "seq_test" | |
MYSQL_USER: "test" | |
MYSQL_PASSWORD: "1234" | |
MYSQL_ROOT_PASSWORD: "toor" | |
mariadb: | |
image: mariadb:10 | |
environment: | |
MYSQL_DATABASE: "seq_test" | |
MYSQL_USER: "test" | |
MYSQL_PASSWORD: "1234" | |
MYSQL_ROOT_PASSWORD: "toor" | |
postgres: | |
image: postgres | |
environment: | |
POSTGRES_PASSWORD: "1234" | |
POSTGRES_USER: "test" | |
POSTGRES_DB: "seq_test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.1-alpine | |
RUN set -ex \ | |
&& apk --no-cache add postgresql-dev | |
RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Test sequence support of different DBMS | |
// Build Dockerfile (PHP with database support) with | |
// docker build -t php-dbms . | |
// Then run this script with | |
// docker run -it --rm -v (pwd):/app -w /app --net=doctrine-sequences_default php-dbs php index.php | |
use Doctrine\DBAL\DriverManager; | |
require_once 'vendor/autoload.php'; | |
$urls = [ | |
"sqlite:///mydb.slite", | |
"mysql://test:1234@mysql5:3306/seq_test", | |
"mysql://test:1234@mysql8:3306/seq_test", | |
"mysql://test:1234@mariadb:3306/seq_test", | |
"pgsql://test:1234@postgres:5432/seq_test", | |
]; | |
foreach($urls as $url) { | |
echo "Tying $url\n"; | |
try { | |
$conn = DriverManager::getConnection(["url" => $url]); | |
printf("Supports sequences: %d\n", $conn->getDatabasePlatform()->supportsSequences()); | |
printf("Next sequence SQL: %s\n", $conn->getDatabasePlatform()->getSequenceNextValSQL("myseq")); | |
} catch (Exception $e) { | |
printf("ERROR: %s\n", $e->getMessage()); | |
} | |
echo "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment