PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE `dataLink` ( `dataLinkID` INT unsigned NOT NULL AUTO_INCREMENT, `dataLink` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (`dataLinkID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; INSERT INTO `dataLink` (`dataLink`) VALUES ('TEST1'), ('TEST2'), ('TEST3'), ('TEST4'), ('TEST5');
Copy Clear
Copy Format Clear
<?php 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 using Laravel $version = $db::select($query); printf('DB version (Laravel Query Builder): %s ' . PHP_EOL, $version[0]->version); $query2 = "SELECT * FROM `dataLink` WHERE `dataLinkID` = :dataLinkID;"; // get DB version using PDO $stmt = $pdo->prepare($query2); $results = []; foreach ([1,2,3,4,5] as $dataLinkID) { $stmt->execute([dataLinkID=>$dataLinkID]); $results[$dataLinkID] = $stmt->fetchAll(PDO::FETCH_ASSOC); } echo json_encode($results, JSON_PRETTY_PRINT);
Show:  
Copy Clear