MongoDB-Why does PHP insert integer number 8 into MONGO, which becomes numberint (8)?

Source: Internet
Author: User
Keywords Php mongodb
Tags mongo shell
PHP inserts 8 into the data using the Update method in the MONGO driver for an array of integers (such as the array, list:[1,3,4]), and becomes Numberlong (8).
Convert 8 to two classes defined in the driver: Mongoint32 and Mongoint64 are also not correct, this time the display is Numberint (8), Numberlong (8).
Inserting inside the MONGO shell is no problem, it is 8.
Thank you.

Reply content:

PHP inserts 8 into the data using the Update method in the MONGO driver for an array of integers (such as the array, list:[1,3,4]), and becomes Numberlong (8).
Convert 8 to two classes defined in the driver: Mongoint32 and Mongoint64 are also not correct, this time the display is Numberint (8), Numberlong (8).
Inserting inside the MONGO shell is no problem, it is 8.
Thank you.

Don't know exactly what type of data you need.

Insert integer number 8, becomes NumberInt(8) not normal?

In the MONGO shell, the number defaults to the double type

$type-mongodb Manual 3.2

For example, if you insert the number 8, you can double find the document with NUM as the type (that is, $type 1).test_doc

db.collection_example.insert({_id: 'test_doc', num: 8})db.collection_example.find({num: {$type: 1}})
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.