Hi! Could we please enable some services and cookies to improve your experience and our website?
No, thanks.
Okay!
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
-- Create bookings table
CREATE TABLE IF NOT EXISTS bookings (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
phone VARCHAR(20) NOT NULL,
date DATE NOT NULL,
time TIME NOT NULL,
guests INT NOT NULL,
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
SQL Server:
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
MySQL 9.3.0
MariaDB 11.4
MariaDB 11.8
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
PostgreSQL 16
PostgreSQL 17 + PostGIS
PostgreSQL 17 + PostGIS WorkShop (ReadOnly)
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
RedDatabase 5.0
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
ClickHouse
Run SQL code
Save snippet
ER Diagram
<?php
// Format date manually since Carbon might not be available
$now = date('d/m/Y');
printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion());
// Define query
$query = "SELECT VERSION() as version;";
// Check if PDO connection is available
if (isset($pdo)) {
try {
// Get DB version using PDO
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
printf('DB version (PDO): %s ' . PHP_EOL, $row['version']);
} catch (PDOException $e) {
echo "PDO Error: " . $e->getMessage() . PHP_EOL;
}
}
// Check if mysqli connection is available
if (isset($mysqli)) {
try {
// Run query using mysqli
$result = $mysqli->query($query);
if ($result) {
$version = $result->fetch_object();
printf('DB version (mysqli): %s ' . PHP_EOL, $version->version);
} else {
echo "MySQLi query error: " . $mysqli->error . PHP_EOL;
}
} catch (Exception $e) {
echo "MySQLi Error: " . $e->getMessage() . PHP_EOL;
}
}
// Laravel query builder is likely not available in standard PHP hosting
// Checking if it exists before attempting to use it
if (isset($db) && method_exists($db, 'select')) {
try {
$version = $db::select($query);
printf('DB version (Laravel Query Builder): %s ' . PHP_EOL, $version[0]->version);
} catch (Exception $e) {
echo "Laravel DB Error: " . $e->getMessage() . PHP_EOL;
}
} else {
echo "Laravel Query Builder not available" . PHP_EOL;
}
?>
PHP version :
PHP 7.4
PHP 8.0
PHP 8.1
PHP 8.2
PHP 8.3
PHP 8.4
Run PHP Code
Save snippet