Answer the question
In order to leave comments, you need to log in
How to assign responses from the database to a variable?
Hello. I make a request to the database:
$id = "53";
const SQL_ALL_FOR_LOG = '
SELECT * FROM main WHERE id = :id
';
$pdo = new PDO($dsn, $user, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare(SQL_ALL_FOR_LOG);
$res = $stmt->execute([':id' => $id]);
$row = json_encode($stmt->fetchAll(PDO::FETCH_OBJ));
echo "$row";
[{"id":"53","namenomer":"lux","datestart":"2016-12-22","dateend":"2016-12-24"}]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question