我想“复制”一个 ORM 对象,然后将其保存到数据库中(使用新的主键),但我无法取消设置复制对象的主键。
$orm1 = new Model1($id);
if($orm1->loaded()) {
$orm2 = $orm1;
$orm2->id = null; //something like this?
unset($orm2->_primary_key); //or like this?
$orm2->save(); //I would like to create a new entry in the db but it doesn't work
}
我希望我足够清楚......基本上,我怎样才能在数据库中“再次保存”一个模型......?