以下是我创建锦标赛并保存的方法:
$tournament = new Entities\Tournament();
$tournament->setTitle("this is strange");
var_dump($tournament->getTitle());
$this->em->persist($tournament);
$this->em->flush();
这是锦标赛课程:
<?php
namespace Entities;/** * @Entity @Table(name="jos_gsa_tournament") */
use \Doctrine\Common\Collections\ArrayCollection;
class Tournament { /** @Id @Column(type="integer") @GeneratedValue */
protected $id;//** @Id @Column(type="integer") */
protected $title;//** @Column(type="string",length=255) */
public function getId() {
return $this->id;
}
public function setId($id) {
$this->id = $id;
}
public function getTitle() {
return $this->title;
}
public function setTitle($title) {
$this->title = $title;
}
}
?>
运行上面提到的代码后,我在数据库中有一个锦标赛条目,标题为空字符串。即使var_dump转储&#34;这很奇怪&#34;。
答案 0 :(得分:1)
您的注释语法看起来不正确。看起来应该是这样......
namespace Entities;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="jos_gsa_tournament")
*/
class Tournament {
/** @Id @Column(type="integer") @GeneratedValue */
protected $id;
/** @Column(type="string",length=255) */
protected $title;
答案 1 :(得分:0)
搞砸了我的注释,应该是:
<?php
namespace Entities;
use \Doctrine\Common\Collections\ArrayCollection;
/** * @Entity @Table(name="jos_gsa_tournament") */
class Tournament {
/** @Id @Column(type="integer") @GeneratedValue */
protected $id;
/** @Column(type="string",length=255) */
protected $title;