Mongodb-why does php insert integer 8 into mongo and convert it to numberint (8 )?

Source: Internet
Author: User
Tags mongo shell
Php uses the update method in the mongo driver to insert 8 data into an integer array (the array is like this, list: [, 4]) and converts it to numberlong (8 ). Converting 8 to the two classes defined in the driver: Optional int32 and optional int64 is also incorrect. The displayed numberint (8 )... php uses the update method in the mongo driver to insert 8 data into an integer array (the array is like this, list: [, 4]) and converts it to numberlong (8 ).
Converting 8 to the two classes defined in the driver: Optional int32 and optional int64 is also incorrect. At this time, numberint (8) and numberlong (8) are displayed ).
There is no problem with inserting in mongo shell, which is 8.
Thank you.

Reply content:

Php uses the update method in the mongo driver to insert 8 data into an integer array (the array is like this, list: [, 4]) and converts it to numberlong (8 ).
Converting 8 to the two classes defined in the driver: Optional int32 and optional int64 is also incorrect. At this time, numberint (8) and numberlong (8) are displayed ).
There is no problem with inserting in mongo shell, which is 8.
Thank you.

It's not clear what type of data you actually need

Insert an integer of 8NumberInt (8)Isn't it normal?

In mongo shell, the number is of the double type by default.

$ Type-MongoDB Manual 3.2

For example, if you want to insert the number 8, you can findDoubleType (that is, $ type is 1) of the document, findTest_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.