search
Homephp教程PHP源码mongodb学习笔记2(简单增删查改)

1.增加一条数据。昨天也练习了一下,今天又进一步巩固。主要有两种方法,一种是save,一种是insert。举例:db.blog.save(({"name":"taotao","address":{"city":"beijing","post":"100096"},"phone":"64645646"}))或者db.blog.insert(({"name":"taotao","address":{"city":"beijing","post":"100096"},"phone":"15210340214"}))。另外可以先给一个变量赋值,然后插入这个变量即可。例如
post={
... "name" : "taotao",
... "address" : {
... "city" : "beijing",
... "post" : "100096"
... },
... "phone" : "15210340214"
... }
db.blog.insert(post);
2,删除一条记录db.集合名.remove(条件);如:db.blog.remove({"name":"ysz"})删除集合中name为ysz的数据
删除全部记录 db.集合名.remove();不写任何条件就相当于删除所有数据。如:db.blog.remove();
3.查询所有记录db.集合名.find();如:db.blog.find();查找集合lblog中所有数据
查询所有记录db.集合名.findOne(条件);如:db.blog.findOne({"name":"ysz"});查找集合中name为ysz的数据
这是简单的查询,明天学习各种条件查询。
4.修改记录db.集合名.update(条件);db.blog.update({"name":"ysz"},{"name":"taotao"})按理说不写条件,应该是全部修改的,但实际结果却只修改了一条,这个先存疑。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.