GithubHelp home page GithubHelp logo

Comments (3)

jmikola avatar jmikola commented on July 1, 2024

There is not currently a method for this, but we can certainly consider adding it in a future 1.x release (e.g. 1.2). I'll make a ticket on the PHPC project this week to track the request, and cross-reference it here.

In the meantime, you should be able to use hex2bin() on the string representation of the ID (__toString() returns a 24-character hexadecimal string) and then use unpack() to extra the first four bytes. You may find the code from mongofill's MongoId implementation a helpful reference for that.

from mongo-php-library.

sshilko avatar sshilko commented on July 1, 2024

thx i will use unpack, just migrated from mongo to mongodb extension, looks good so far.

from mongo-php-library.

jmikola avatar jmikola commented on July 1, 2024

Tracking ticket: PHPC-552. Also, a more convenient solution may be to use hexdec() on the first 8 bytes of the ObjectID's hexadecimal representation. See: https://github.com/alcaeus/mongo-php-adapter/blob/ef2f253ba47e376ba220ba1cde753c99a51e2705/lib/Mongo/MongoId.php#L174

from mongo-php-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.