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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -