我有一些表store_section(id,parent_id,label),我想改变一些行,设置PARENT_ID = NULL.
我试图:
$record = $table->getTable()->find( $id );
$record->parent_id = null;
$record->save();
Run Code Online (Sandbox Code Playgroud)
但这不起作用.如何在Doctrine中的表中设置NULL,在上面的示例中,parent_id变为= 0(不是= NULL)?
Thnx的回复!
小智 12
我会尝试以下之一:
1:
$record = $table->getTable()->find( $id );
$record->parent_id = new Doctrine_Null();
$record->save();
Run Code Online (Sandbox Code Playgroud)
2:
$record = $table->getTable()->find( $id );
$record->parent_id = "NULL";
$record->save();
Run Code Online (Sandbox Code Playgroud)
我没有测试过这些,但我记得之前有过类似的问题,只是不记得我是如何解决它的.希望这可以帮助!
您可以使用方法集('u.name','NULL')例如:
Doctrine_Query::create()->update('User u')->set('u.name', 'NULL')->where('u.id = ?',$id);
Run Code Online (Sandbox Code Playgroud)