Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony(原则)在保存时尝试插入空相关对象_Php_Symfony 1.4_Doctrine 1.2 - Fatal编程技术网

Php Symfony(原则)在保存时尝试插入空相关对象

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:

我从事symfony 1.4(条令)项目。我已将关系添加到我的sfGuardUserProfile模型中:

    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
,这不是问题。然后我就不提您的问题了(:祝您好运。您解决过这个问题吗?我也遇到了同样的问题