When I switch from PHP 5.6 to 7.0 or 7.2., this statement does not work anymore:
$translator = new stdClass();
$sql = "SELECT name, value FROM ".$tab_translator." WHERE lang_id=:lang_id";
try {
$fetchTextTranslated = $conn->prepare($sql);
$fetchTextTranslated->bindValue(':lang_id', (int) trim($translator_lang_id), PDO::PARAM_INT);
$fetchTextTranslated->execute();
}
catch(PDOException $e) {
if ($config->debug==1) { echo 'Error: ' . $e->getMessage(); }}
while ($textTranslated = $fetchTextTranslated->fetch(PDO::FETCH_ASSOC)) {
$translator->$textTranslated['name']=$textTranslated['value'];
}
When I echo $textTranslated['name']
or $textTranslated['value']
I do get data from the table. But I want fetched-data to be in the form of stdClass object $translator and this does not work anymore in PHP 7 and higher.
I would appreciate your help.