ThinkPHP5 数据库插入数据

编程入门 行业动态 更新时间:2024-10-07 02:19:48

ThinkPHP5 <a href=https://www.elefans.com/category/jswz/34/1771350.html style=数据库插入数据"/>

ThinkPHP5 数据库插入数据

<?phpnamespace app\index\controller;use think\Controller;
use think\Db;class Index extends Controller
{public function index(){$db = Db::name('user');# insert 返回值是影响记录的行数 插入数// $res = $db->insert([//     'email' => 'imooc_1@qq',//     'password' => md5('imooc_1'),//     'username' => 'imooc_1'// ]);#insertGetId 返回值插入数据的自增id// $res = $db->insertGetId([//     'email' => 'imooc_1@qq',//     'password' => md5('imooc_1'),//     'username' => 'imooc_1'// ]);#insertAll 返回插入数据成功的行数$data = [];for($i=10; $i<20; $i++){$data[] = ['email' => "imooc_{$i}@qq",'password' => md5("imooc_{$i}"),'username' => "imooc_{$i}"];}$res = $db->insertAll($data);dump($res);}
}?>

 

更多推荐

ThinkPHP5 数据库插入数据

本文发布于:2024-03-12 14:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1731716.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!