PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE records ( name TEXT, route TEXT ); INSERT INTO records (name, route) VALUES ('Coloured', 'Toyusu Tunnel Drag'); INSERT INTO records (name, route) VALUES ('Ruli', 'Kiba to Ariake R'); SELECT * FROM records;
Copy Clear
Copy Format Clear
<?php // Include Composer's autoloader require __DIR__.'/vendor/autoload.php'; // Bootstrap Laravel $app = require_once __DIR__.'/bootstrap/app.php'; // Get the service container $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); // Now you can use Laravel's DB facade use Illuminate\Support\Facades\DB; use Carbon\Carbon; $now = Carbon::now()->format('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); $query = "SELECT VERSION() as version;"; // 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']); // Run query using mysqli $result = $mysqli->query($query); $version = $result->fetch_object(); printf('DB version (mysqli): %s ' . PHP_EOL, $version->version); // Select data from records table using Laravel Query Builder $query = "SELECT * FROM records"; $records = DB::select($query); // Print out the records printf("Database data: \n"); foreach ($records as $record) { printf("Record ID: %d, Name: %s\n", $record->id, $record->name); }
Show:  
Copy Clear