当前位置:网站首页>Tp6 fast installation uses mongodb to add, delete, modify and check
Tp6 fast installation uses mongodb to add, delete, modify and check
2022-07-03 01:19:00 【Life goes on and battles go on】
Preface
MongoDB Is a document database in a non relational database .MongoDB It's for the rapid development of the Internet Web application And the designed database system . MongoDB The goal of our design is minimalism 、 flexible 、 As Web Part of the application stack . MongoDB The data model of is document oriented , The so-called document is similar to JSON Structure , Simple understanding MongoDB There are all kinds of things in this database JSON.
One 、 Basic concepts :
Example :pandas Is based on NumPy A tool of , The tool is created to solve data analysis tasksfile (document): Be similar to JS Objects in the , stay MongoDB The number of each item in It's all a document .
aggregate (collection): A collection is a set of documents , That is, a collection is used to store text Stall . The documents stored in the collection can be various , No lattice The formula demands .
Multiple documents make up a collection , Multiple collections make up a database
Use
1. stay config/database In file
'mongodb' => [
// Database type
'type' => 'mongo',
// Server address
'hostname' => '127.0.0.1',
// Database name
'database' => 'goods',
// user name
'username' => '',
// password
'password' => '',
// port
'hostport' => '27017',
// Database connection parameters
'params' => [],
// Database mode
'debug' => env('database.debug', true),
// Database deployment :0 Centralized ( Single server )1 Distributed ( Master slave server )
'deploy' => 0,
// Whether the reading and writing of data Office database are classified Master slave is effective
'rw_separate' => false,
// monitor sql
'trigger_sql' => true,
// After the separation of reading and writing , Number of servers
'master_num' => 1,
// Specify the slave server serial number
'slave_no' => '',
// Whether to strictly check whether the field exists
'fields_strict' => true,
// Whether it needs to be disconnected and reconnected
'break_reconnect' => false,
// Field cache path
'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
]
Realization curd operation
add to
// Receiving parameters
$postData = $request->post();
$data = Db::connect('mongodb')->table('goods')->insert($postData);
dd($data)
Inquire about
// call mongodb Query data
$data = Db::connect('mongodb')->table('goods')->select()->toArray();
dd($data);
Conditional query
// Conditional query
$comment = Db::connect('mongo')->table('comments')->where('product_id',intval($product_id))->select()->toArray();
Delete
// Delete data
Db::connect('mongodb')->table('goods')->where('_id', $id)->delete();
边栏推荐
- 基本远程连接工具Xshell
- Database SQL language 02 connection query
- Inversion de l'intervalle spécifié dans la liste des liens
- [C language] branch and loop statements (Part 1)
- excel去除小数点后面的数据,将数字取整
- 【FPGA教程案例5】基于vivado核的ROM设计与实现
- R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
- 电话网络问题
- 异步、邮件、定时三大任务
- 链表内指定区间反转
猜你喜欢
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
The arm core board / development board of Feiling equipped with Ti am62x made its debut in embedded world 2022
异步、郵件、定時三大任務
Matlab saves the digital matrix as geospatial data, and the display subscript index must be of positive integer type or logical type. Solve the problem
Cut point of undirected graph
Basic concept and implementation of overcoming hash
JDBC courses
MySQL基础用法02
RISA rz/g2l processor introduction | frame diagram | power consumption | schematic diagram and hardware design guide
Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)
随机推荐
Kivy教程大全之如何在 Kivy 中创建下拉列表
kivy教程之在 Kivy App 中使用 matplotlib 的示例
Kivy tutorial - example of using Matplotlib in Kivy app
Trois tâches principales: asynchrone, courrier et timing
异步、邮件、定时三大任务
MySQL foundation 04 MySQL architecture
matlab 多普勒效应产生振动信号和处理
[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)
(C language) data storage
Specified interval inversion in the linked list
MySQL --- 数据库查询 - 基本查询
Now that the teenager has returned, the world's fireworks are the most soothing and ordinary people return to work~
不登陆或者登录解决oracle数据库账号被锁定。
MySQL
按键精灵打怪学习-前台和内网发送后台验证码
Leetcode 6103 - minimum fraction to delete an edge from the tree
拥抱平台化交付的安全理念
Every k nodes in the linked list are flipped
Excel calculates the difference between time and date and converts it into minutes
[system analyst's road] Chapter V double disk software engineering (development model development method)