Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Updatebypk运行一条Sql语句,save()运行两条?

$
0
0
下面这个方法要先select,然后再update
$post=Post::model()->findByPk(10);
$post->title='new post title';
$post->save(); // 将更改保存到数据库


而这个只用一条update语句
Post::model()->updateByPk($pk,$attributes,$condition,$params);


所以如果为了性能尽量用第二个方法?我理解对吗?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>