群友提出一个问题,如何在更新某个字段的时候同步另一个字段数据过来,即
update table set column1 =column2 where xxx
写原生SQL当然可行,不过既然有ORM那就应该尝试着封装为ORM,找了找手册,尝试了一下这个
<?
php
$res=M('user')->where(array("id"=>2))->save(
array(
"email"=>
array("exp","username"
)
));
?>
好了 果然把 email的数据同步为 username的数据了
转载于:https://www.cnblogs.com/lizhaoyao/p/7049407.html