Php Symfony(原则)在保存时尝试插入空相关对象
我从事symfony 1.4(条令)项目。我已将关系添加到我的sfGuardUserProfile模型中:Php Symfony(原则)在保存时尝试插入空相关对象,php,symfony-1.4,doctrine-1.2,Php,Symfony 1.4,Doctrine 1.2,我从事symfony 1.4(条令)项目。我已将关系添加到我的sfGuardUserProfile模型中: sfGuardUserProfile: tableName: sf_guard_user_profile columns: id: { type: integer(20), primary: true, autoincrement: true } user_id:
sfGuardUserProfile:
tableName: sf_guard_user_profile
columns:
id: { type: integer(20), primary: true, autoincrement: true }
user_id: { type: integer(20), notnull: true }
username: { type: string(128), notnull: false }
...
city: { type: string(255) }
...
relations:
User:
class: sfGuardUser
foreign: id
local: user_id
type: one
onDelete: cascade
foreignType: one
foreignAlias: Profile
...
RelatedCity:
class: City
local: city
foreign: woeid
onDelete: cascade
type: one
现在,当我尝试保存sfGuardUserProfile对象(city值为null)时,它尝试在cities表中创建所有字段为null的新记录,我得到一个sql异常列country\u id不能为null
。country_id是城市表(和模型)中的一个字段。如何防止插入此空城市对象
异常的屏幕截图:
也许这会有帮助:
这是sfGuardUserProfile对象字段的屏幕截图。优点是在RelatedCity对象中,country_id(非DoctrineNull)上有空值如果使用phpMyadmin,您可以在列名附近选中
null
或EMPTY
,这不是问题。然后我就不提您的问题了(:祝您好运。您解决过这个问题吗?我也遇到了同样的问题