php - Creating object name with dash -
i trying run mysqli query retrieve single result, requires me create object contains dash in name, won't work.
$style_name = $db2->query("select modeldesc-enu tlkpmodel modelid = '$style' limit 1")->fetch_object()->modeldesc-enu;
notice part fetch_object()->modeldesc-enu;
- it's invalid object name. how around this?
wrap property in curly braces , quotes:
fetch_object()->{'modeldesc-enu'};
although suspect need wrap column name in ticks, too, dash not valid identifier characters , means subtracting enu modeldesc.
$style_name = $db2->query("select `modeldesc-enu` tlkpmodel modelid = '$style' limit 1")->fetch_object()->{'modeldesc-enu'};
Comments
Post a Comment