当前位置:网站首页>tp6快速安装使用MongoDB实现增删改查
tp6快速安装使用MongoDB实现增删改查
2022-07-03 00:56:00 【生命不止、战斗不息】
前言
MongoDB是非关系型数据库中的文档数据库。MongoDB是为快速开发互联网Web应用 而设计的数据库系统。 MongoDB的设计目标是极简、灵活、作为 Web应用栈的一部分。 MongoDB的数据模型是面向文档的,所谓文档是一种类似于JSON的结构,简单理解 MongoDB这个数据库中存的是各种各样的 JSON。
一、基本概念:
示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的文档(document):类似于JS中的对象,在MongoDB中每一条数 据都是一个文档。
集合(collection):集合就是一组文档,也就是集合是用来存放文 档的。集合中存储的文档可以是各种各样的,没有格 式要求。
多个文档组成集合,多个集合组成数据库
使用
1.在config/database文件中
'mongodb' => [
//数据库类型
'type' => 'mongo',
//服务器地址
'hostname' => '127.0.0.1',
//数据库名
'database' => 'goods',
//用户名
'username' => '',
//密码
'password' => '',
//端口
'hostport' => '27017',
//数据库连接参数
'params' => [],
//数据库调式模式
'debug' => env('database.debug', true),
//数据库部署方式:0集中式(单一服务器)1 分布式(主从服务器)
'deploy' => 0,
//数据局库读写是否分类 主从式有效
'rw_separate' => false,
//监听sql
'trigger_sql' => true,
//读写分离后,朱服务器数量
'master_num' => 1,
//指定从服务器序号
'slave_no' => '',
//是否严格检查字段是否存在
'fields_strict' => true,
//是否需要断线重连
'break_reconnect' => false,
//字段缓存路径
'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
]实现curd操作
添加
// 接收参数
$postData = $request->post();
$data = Db::connect('mongodb')->table('goods')->insert($postData);
dd($data)查询
//调用mongodb 查询数据
$data = Db::connect('mongodb')->table('goods')->select()->toArray();
dd($data);带条件查询
//带条件查询
$comment = Db::connect('mongo')->table('comments')->where('product_id',intval($product_id))->select()->toArray();
删除
//删除数据
Db::connect('mongodb')->table('goods')->where('_id', $id)->delete();边栏推荐
- leetcode 6103 — 从树中删除边的最小分数
- matlab查找某一行或者某一列在矩阵中的位置
- Linear programming of mathematical modeling (including Matlab code)
- SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
- 【无标题】
- 电话网络问题
- Delete duplicate elements in the ordered linked list -ii
- leetcode:701. Insertion in binary search tree [BST insertion]
- R language uses coin package to apply permutation tests to independence problems (permutation tests, whether response variables are independent of groups, are two numerical variables independent, and
- 2022 coal mine gas drainage examination question bank and coal mine gas drainage examination questions and analysis
猜你喜欢

Rk3568 development board evaluation (II): development environment construction

Machine learning terminology
![leetcode:701. Insertion in binary search tree [BST insertion]](/img/bc/1dda73198488eb81b49be2c1dff6c2.png)
leetcode:701. Insertion in binary search tree [BST insertion]

Foundations of data science is free to download

Infrared thermography temperature detection system based on arm rk3568
![[case sharing] let the development of education in the new era advance with](/img/11/af88d16dc66f00840cbfc5ba5d68bd.jpg)
[case sharing] let the development of education in the new era advance with "number"

Thank you for being together for these extraordinary two years!

Asynchronous, email and scheduled tasks

【爱死机】《吉巴罗》被忽略的细节
![[AUTOSAR 11 communication related mechanism]](/img/bf/834b0fad3a3e5bd9c1be04ba150f98.png)
[AUTOSAR 11 communication related mechanism]
随机推荐
按鍵精靈打怪學習-多線程後臺坐標識別
18_微信小程序之微信视频号滚动自动播放视频效果实现2.0
Basic remote connection tool xshell
[overview of AUTOSAR four BSW]
按键精灵打怪学习-自动寻路回打怪点
1696C. Fishingprince Plays With Array【思维题 + 中间状态 + 优化存储】
Initial order of pointer (basic)
[AUTOSAR I overview]
[shutter] animation animation (shutter animation type | the core class of shutter animation)
1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]
How to convert Quanzhi a40i/t3 to can through SPI
[shutter] image component (cached_network_image network image caching plug-in)
【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
(C language) data storage
Reading and writing speed of Reza rz/g2l arm development board storage and network measurement
excel表格计算时间日期的差值,并转化为分钟数
Rk3568 development board evaluation (II): development environment construction
12_微信小程序之微信视频号滚动自动播放视频效果实现
[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)
Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)