9951 explained code solutions for 126 technologies


php-pdoFetch single row with PHP PDO


$st = $pdo->prepare('SELECT * FROM test LIMIT 1');
$st->execute();
$row = $st->fetch(PDO::FETCH_ASSOC);ctrl + c
$pdo->prepare

prepare given query to execute

$st->execute(

run query on the server

fetch

returns single row from resulting set

FETCH_ASSOC

will return row as an associative array (rather than numbered array)