// try to find a row
$model = someModel::find()
...
->one();
// if exist a row, return the model
// otherwise return null
// now check if the model is null
if (is_null($model)) {
$model = new someModel();
}
// apply your change
$model->attributes = $attributes;
...
// insert or update
$model->save();
YII Insert or Update a Row
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
win 环境下 docker 的使用整理
原創
2024-05-17 00:25:04
MySQL 核心模块揭秘 | 16 期 | InnoDB 表锁
原創
2024-05-17 12:02:59
DataCube 漏洞小结
原創
2024-05-30 11:16:40
智能的PHP开发工具PhpStorm v2024.1全新发布——支持PHPUnit 11.0
原創
2024-05-24 12:20:21
php 异步执行方法,父进程继续执行下面的代码 执行完成后,父进程自动关闭, 子进程继续执行
原創
2024-05-24 09:27:59
mysql utf8_unicode_ci 与 utf8_general_ci
原創
2024-05-24 00:56:30
Buzz库网络爬虫实例:快速爬取百度搜索实时热点
原創
2024-05-24 00:08:55
昔日辉煌不再,PHP老矣,尚能饭否?
原創
2024-05-23 23:48:42
上海站丨飞天技术沙龙 Serverless + AI 专场开启报名!
原創
2024-05-23 21:13:46
MySQL全文索引源码剖析之Insert语句执行过程
原創
2024-05-20 10:59:15
记一次有点抽象的渗透经历
原創
2024-05-17 23:16:30
浅析MySQL 8.0直方图原理
原創
2024-05-27 10:58:41
基于日志或 gv$sql_audit 分析 OB 异常重试 SQL
原創
2024-05-24 00:02:11
MySQL 核心模块揭秘 | 17 期 | InnoDB 有哪几种行锁?
原創
2024-05-23 00:11:23