我有一個名爲Plato的類,它擴展了Producto witch包含deatribute precio。設置器定義如下:在symfony中插入 double值與doctrine
public function setPrecio(\double $precio)
{
$this->precio = $precio;
return $this;
}
而且我想一個新的元素添加到數據庫與:
$plato = new Plato;
$em = $this->getEntityManager();
// I have tryed this three ways to insert
$plato->SetPrecio(doubleval($precio));
$plato->SetPrecio((double) 2);
$plato->SetPrecio(2.0);
$em->flush();
它給了我下面的錯誤信息:
Catchable Fatal Error: Argument 1 passed to Servinow\EntitiesBundle\Entity\Producto::setPrecio() must be an instance of double, double given, called in /Users/luis/git/servinowServer-luis/src/Servinow/EntitiesBundle/Entity/PlatoRepository.php on line 41 and defined in /Users/luis/git/servinowServer-luis/src/Servinow/EntitiesBundle/Entity/Producto.php line 169
我瞎搞試圖想辦法幫助,並且我在php'echo gettype(9.4)中發現了這個行爲; var_dump(9.4);'現在我的頭腦受傷了。 – Dale