badlamer / propel-uuid-behavior
帮助您设置固定UUID的Propel行为
0.2.0
2015-11-18 10:41 UTC
Requires
- php: >=5.3.3
- propel/propel1: ~1.6
- ramsey/uuid: ~3.0
Requires (Dev)
- phpunit/phpunit: > 4.7, < 6
This package is not auto-updated.
Last update: 2024-09-28 15:28:55 UTC
README
帮助您为Propel ActiveRecord添加UUID
需求
此行为需要Propel >= 1.6.0和Ramsey\Uuid for PHP >= 5.4
安装
通过克隆此仓库或使用Composer(推荐)来获取代码
{ "require": { "badlamer/propel-uuid-behavior": "dev-master" } }
然后,如果您不使用Composer或应用程序中的自动加载器,请将以下配置添加到您的build.properties
或propel.ini
文件中
propel.behavior.uuid.class = vendor.badlamer.propel-uuid-behavior.src.UuidBehavior
注意:
vendor.badlamer.propel-uuid-behavior.src.UuidBehavior
是以"点路径"表示法访问UuidBehavior
类的路径。
然后在您的schema.xml
中声明该行为
<table name="person"> <!-- Explict define a column, else the beavior would create a colum called "uuid". We need to have at least one column with primaryKey="true" to avoid the error: >>Fatal error: Uncaught Error: Call to a member function getPhpName() on null in [...] vendor/propel/propel1/generator/lib/builder/om/QueryBuilder.php:478<< --> <column name="id" type="CHAR" size="36" required="true" primaryKey="true" /> <!-- We are linking the column with the name >>id<< to the behavior. Now the uuid generation is used for each new created entity. --> <behavior name="uuid"> <parameter name="name" value="id" /> </behavior> </table>