symfony - Decimal return string in Doctrine -


i have field decimal this

 /**  *  * @orm\column(name="foo", type="decimal", precision=0, scale=2, nullable=false, unique=false)  */ private $foo; 

when use getfoo() or querybuilder value "159.79" instead of 159.79. how can correct type?

even though have declared decimal in doctrine annotation, when retrived php treat string.
reference here.

values retrieved database converted php’s string type or null if no data present.

you change getter cast float , return.
e.g.

public function getfoo() {     return (float) $this->foo; } 

or

public function getfoo() {     return floatval($this->foo); } 

look @ type juggling more info.
more info on floatval() here


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -