[英]Doctrine mapping field error
我有一个实体,具有2个属性_obc_id,obc_id
class myEntity {
...
/**
* @ORM\Column(name="obc_id", type="integer", nullable=false)
*/
private $obc_id;
/**
* @ORM\Column(name="_obc_id", type="integer", nullable=false)
*/
private $_obc_id;
public function get_obcId()
{
return $this->_obc_id;
}
public function getObcId()
{
return $this->obc_id;
}
public function set_obcId($value);
{
$this->_obc_id = $value;
return $this;
}
public function setObcId($value);
{
$this->obc_id = $value;
return $this;
}
}
主义不能调用set_obcId(),get_obcId(),它返回“既不是属性也不是方法之一”,我也写了一个__set和__get,但是它不起作用。
如果要以这种方式使用getter / setter,请尝试重命名变量:
private $obcId;
private $_obcId;
但是,我建议不要使用两个如此相似的列名,也不要在列名的开头使用下划线(因此也不要在变量名中使用下划线)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.