Skip to content

Commit

Permalink
add doctrine uuid type
Browse files Browse the repository at this point in the history
  • Loading branch information
lcp0578 committed May 20, 2019
1 parent b92fab4 commit 1b1acd6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [Doctrine](src/symfony/Doctrine/README.md) Doctrine相关
- [Doctrine](src/symfony/Doctrine/Doctrine.md) Doctrine基础知识
- [Doctrine Types](src/symfony/Doctrine/Types.md) Doctrine字段类型
- [Doctrine Uuid Type](src/symfony/Doctrine/UuidType.md) UuidType自定义字段类型
- [An Entity Demo](src/symfony/Doctrine/Entity.md) 一个略复杂的Entity的示例
- [Validation Constraints](src/symfony/Doctrine/constraints.md) 验证约束设置
- [Custom Constraint.md](src/symfony/Doctrine/custom_constraint.md)自定义验证约束
Expand Down
4 changes: 4 additions & 0 deletions src/git/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

# git --version
git version 1.7.1
- 卸载系统自带的低版本git

# yum remove git
- 升级git
- 更新yum

Expand All @@ -16,6 +19,7 @@
- 下载git源码包

wget https://github.com/git/git/archive/v2.18.0.tar.gz
//或 https://mirrors.edge.kernel.org/pub/software/scm/git/
- 解压、安装

# tar -zxvf v2.18.0.tar.gz
Expand Down
36 changes: 36 additions & 0 deletions src/symfony/Doctrine/UuidType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Doctrine Uuid Type
> https://github.com/ramsey/uuid-doctrine
- config.yml

# app/config/config.yml
doctrine:
dbal:
types:
uuid: Ramsey\Uuid\Doctrine\UuidType
- Usage
Then, in your models, you may annotate properties by setting the @Column type to uuid, and defining a custom generator of Ramsey\Uuid\UuidGenerator. Doctrine will handle the rest.

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="products")
*/
class Product
{
/**
* @var \Ramsey\Uuid\UuidInterface
*
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
*/
protected $id;

public function getId()
{
return $this->id;
}
}
1 change: 1 addition & 0 deletions src/symfony/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#### [Doctrine](Doctrine/README.md) Doctrine相关
- [Doctrine](Doctrine/Doctrine.md) Doctrine基础知识
- [Doctrine Types](Doctrine/Types.md) Doctrine字段类型
- [Doctrine Uuid Type](Doctrine/UuidType.md) UuidType自定义字段类型
- [An Entity Demo](Doctrine/Entity.md) 一个略复杂的Entity的示例
- [Validation Constraints](Doctrine/constraints.md) 验证约束设置
- [Custom Constraint.md](Doctrine/custom_constraint.md)自定义验证约束
Expand Down

0 comments on commit 1b1acd6

Please sign in to comment.