Hello,

Does anybody know how to create a GUID (Globally Unique IDentifier) Using PHP.

    Using PHP and what? PHP itself is stateless so everytime someone uses it they get all fresh information.

    If you want a GUID in your database you'll have to figure out if your database can do it by itself (PostgreSQL and Oracle can) or if you'll need to fake it. If you need to fake it you can create a table that just has an auto incrementing field and do an insert into it before any insert into another table, and retrieve the newly created id and use it as your GUID when you insert into your new table.

    But what I'd really like to know is why do you feel you need a GUID? I've never found a good use for them and actually feel that they are more of a pain. Using a unique ID on every record in a table is very useful, but a GUID could belong to any table in your system so when you use it as a foreign key you now have to add logic and code to figure out what table that GUID resides in and what fields you can, and should, retrieve from that table.

      I am using a mysql database, And I need a guid that is unique over different servers as well.
      So it needs to be something like the Microsoft 16-byte guid they use in documents and com objects.
      I need it because it will identify the documents I use all over each server.

      I am thinking about something that creates an id using the mac adress of the network card and a timestamp.

        Good luck. MAC Address and time stamp sounds like a good idea.

          5 months later

          Originally posted by Fall
          I am using a mysql database, And I need a guid that is unique over different servers as well.
          So it needs to be something like the Microsoft 16-byte guid they use in documents and com objects.
          I need it because it will identify the documents I use all over each server.

          I am thinking about something that creates an id using the mac adress of the network card and a timestamp.

          hello,
          I would like to know if you figured it out how to solve the problem. I would be quite interrested.

          thanx
          Sebastian

            I used the timestamp and the ip and md5 encrypted them

              Originally posted by Fall
              I used the timestamp and the ip and md5 encrypted them

              maybe you´ve got a code snipplet for me?

                Write a Reply...