9951 explained code solutions for 126 technologies


php-pdoFetch single column value with PHP PDO


$st = $pdo->prepare('SELECT name FROM test LIMIT 1');
$st->execute();
$value = $st->fetchColumn();ctrl + c
$pdo->prepare

prepare given query to execute

$st->execute(

run query on the server

$st->fetchColumn()

return single column value from resulting set

name

column to get value of