When I retrieve a row from a SQLite3 database, using the default fetch()
mode of both associative and numeric indexes, the numeric index works but I get "undefined index" if I try to use the associative one. That is,
$timeReadBack = $resultArray2[0];
gives the correct result, but
$timeReadBack = $resultArray2['startTime'];
gives "undefined index".
And I'm positive I have the field name correct.
Here's the whole sequence:
$result2 = $db->prepare( 'SELECT parameterValue FROM CurrentState WHERE parameterName = ?;' );
$result2->bindValue(1,'startTime');
$selectStatement = $result2->execute();
$resultArray2 = $result2->fetch();
$timeReadBack = $resultArray2[0];
parameterName
and parameterValue
are TEXT fields in the table.
var_dump($resultArray2)
and see exactly what is in that array! – RiggsFolly Nov 8 '18 at 18:23$resultArray2
That would save us having to play 20 questions with you to get all the relevant information. See Minimal, Complete and Verifiable Example and the perfect question and Question Check list – RiggsFolly Nov 8 '18 at 18:24PDO::FETCH_BOTH
. The field names are case sensitive. Also check the SQL query ifstartTime
is part of the select fields. – F.Igor Nov 8 '18 at 18:27