[英]PropelORM+PostgreSQL: How do I define an SQL-like CHECK constraint on a column in 'schema.xml'?
我試圖在“schema.xml”文件中定義的數據庫模式的一小段:
<table name="hotelroom" phpName="hotelroom">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="room_number" type="varchar" size="10" required="true" />
<column name="price" type="numeric" defaultValue="1000" required="true" />
<unique>
<unique-column name="room_number" />
</unique>
</table>
在 PostgreSQL 的“價格”列中,我會寫CHECK (price > 0::numeric)
,但我似乎無法在這里找到任何方法來實現這一點。我已經檢查了文檔( http://propelorm .org/documentation/reference/schema.html ),但找不到任何關於此的內容。 謝謝你的時間。
您使用的是 v1,但從上面的文檔鏈接看來,您使用的是 v2,
我認為您正在尋找僅從 v2 開始可用的GreaterThan
。
<behavior name="validate">
<parameter name="rule1" value="{column: price, validator: GreaterThan, options: {value: 0, message=Price is not valid}}" />
</behavior>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.