Results of a sql query


I don’t see where is my error ! gr!

$sql ="SELECT * FROM MaTable" ;
$row =$db->getTable('MaTable')->fetchAll ($sql);

if($row) :     
echo $row['Myfield'] ;

error : Warning: Undefined array key “MyField”

Many thanks


I can only guess but fetchAll probably returns an array of rows, where each row is an associative array, which means that if you want the MyField field of the first row, you should access it like that: $row[0]['MyField']

1 Like