Skip to content

Instantly share code, notes, and snippets.

@efiku
Created January 15, 2016 19:07
Show Gist options
  • Save efiku/7e6e4738b7f43619b43c to your computer and use it in GitHub Desktop.
Save efiku/7e6e4738b7f43619b43c to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: efik
* Date: 15.01.16
* Time: 20:03
*/
// Gdzieś w innym pliku połączenie do PDO.
/** @var $polaczenie PDO */
foreach (range(0, 10) as $index) {
$randomNumber = mt_rand(0, 20);
$prepared = $polaczenie->prepare("SELECT costam,costam,costam FROM pytania WHERE id =:id");
$prepared->bindParam(
":id",
$randomNumber,
PDO::PARAM_INT
);
if ($prepared->execute()) {
$question = $prepared->fetchAll(PDO::FETCH_ASSOC);
print_r($question); // Array(19) { ... }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment