「Php/Symfony/Symfony2/doctrine/crud」の版間の差分
ナビゲーションに移動
検索に移動
編集の要約なし |
|||
| 1行目: | 1行目: | ||
==dbに合わせたcontrollerを作成する(crud)== | ==dbに合わせたcontrollerを作成する(crud)== | ||
entityを作成した後controllerを作成するサンプルを以下に | |||
==entityをまずgenerateで作成== | |||
$ php app/console doctrine:generate:entity --entity="AcmeHelloBundle:Blog" --fields="name:string(255) description:text" | $ php app/console doctrine:generate:entity --entity="AcmeHelloBundle:Blog" --fields="name:string(255) description:text" | ||
src/Acme/HelloBundle/Entity/Blog.php | 作られたphp | ||
-src/Acme/HelloBundle/Entity/Blog.php | |||
namespace Acme\HelloBundle\Entity; | namespace Acme\HelloBundle\Entity; | ||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||
2017年1月16日 (月) 14:29時点における版
dbに合わせたcontrollerを作成する(crud)
entityを作成した後controllerを作成するサンプルを以下に
entityをまずgenerateで作成
$ php app/console doctrine:generate:entity --entity="AcmeHelloBundle:Blog" --fields="name:string(255) description:text"
作られたphp -src/Acme/HelloBundle/Entity/Blog.php
namespace Acme\HelloBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Blog
*
* @ORM\Table("blogs")
* @ORM\Entity
*/
class Blog
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="description", type="text")
*/
private $description;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Blog
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param string $description
* @return Blog
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}