Why does not return any results in PDO fetch collum?

2

I made a query and I want to use fetch collum according to a response from the other site;

$query = $pdo->prepare("SELECT b.**, b.**, b.**, b.**, b.**, b.**, b.**, b.**, b.**, b.**, b.token FROM tbl_contas AS b");
    $query->execute();

$iToken = $query->fetchColumn(11);
$tokenHash = $iToken['token'];

Why does not the token return the variable $tokenHash ?

    
asked by anonymous 08.06.2017 / 17:07

1 answer

1

The problem is in the column index the total is 11 however as the documentation informs the count should start at zero.

  

0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement :: fetchColumn () fetches the first column.

Soon in your case change:

$iToken = $query->fetchColumn(11);

To:

$iToken = $query->fetchColumn(10);

Recommended reading:

Documentation - fetchColumn ()

    
08.06.2017 / 17:24