php物件持久化,將物件持久化到資料庫錯誤

2021-10-25 21:09:25 字數 3475 閱讀 1156

我有這個錯誤:

我不明白,我明白錯誤,但我不知道為什麼會發生。

這是我的addcontroller.php檔案:

初始載入工作,但提交表單會生成上述錯誤。但我不知道為什麼。即使我這樣重新排序行:

$tag = new tag();

$tag->setguruid(null);

我的標記實體:

class tag

* @orm\id()

* @orm\generatedvalue()

* @orm\column(type="integer")

private $id;

* @orm\column(type="string", length=125)

private $name;

* @orm\column(type="string", length=255, nullable=true)

private $description;

* @orm\column(type="boolean")

* @orm\column(type="datetime")

private $created_ts;

* @orm\column(type="datetime", nullable=true)

private $last_edit_ts;

* @orm\column(type="integer", nullable=true)

private $guru_id;

public function getid()

return $this->id;

public function getname(): ?string

return $this->name;

public function setname(string $name): self

$this->name = $name;

return $this;

public function getdescription(): ?string

return $this->description;

public function setdescription(?string $description): self

$this->description = $description;

return $this;

return $this;

public function getcreatedts(): ?\datetimeinte***ce

return $this->created_ts;

public function setcreatedts(\datetimeinte***ce $created_ts): self

$this->created_ts = $created_ts;

return $this;

public function getlasteditts(): ?\datetimeinte***ce

return $this->last_edit_ts;

public function setlasteditts(\datetimeinte***ce $last_edit_ts): self

$this->last_edit_ts = $last_edit_ts;

return $this;

public function getguruid(): ?int

return $this->guru_id;

public function setguruid(?int $guru_id): self

$this->guru_id = $guru_id;

return $this;

我的addtype

use symfony\bridge\doctrine\form\type\entitytype;

use symfony\component\form\abstracttype;

use symfony\component\form\extension\core\type\textareatype;

use symfony\component\form\extension\core\type\texttype;

use symfony\component\form\formbuilderinte***ce;

use symfony\component\optionsresolver\optionsresolver;

class addtype extends abstracttype

public function buildform(formbuilderinte***ce $builder, array $options)

$builder->add('name', texttype::class)

->add('description', textareatype::class)

->add('guru_id', entitytype::class, array(

'class' => user::class,

'choice_label' => 'username'

public function configureoptions(optionsresolver $resolver)

$resolver->setdefaults(array(

'data_class' => tag::class

它仍然會給出相同的錯誤,所以我真的不確定它是如何生成的…如何將整數(從entitytype下拉列表中獲取)持久化到資料庫?

謝謝

物件持久化

物件持久化 ifname main read scores pickle 將字典表序列化成字串pickle.dumps 字串變回字典用pickle.loads s import pickle person s pickle.dumps person 序列化 p pickle.loads s 恢復 序...

python 物件持久化

print open persondb.dat rb read testdemo2.py 讀取資料庫 載入乙個例項的時候,類極其模組的檔案都必須匯入 該類的例項再次載入的時候,對類的源 檔案的修改會自動選取 import testdemo import shelve db shelve.open p...

python物件持久化

pickle模組 import pickle person s pickle.dumps person p pickle.loads s pickle.dump person,open pickle db wb p pickle.load open pickle db rb print p prin...