Hello all,

This is more of a database question but since this group contains a lot of
db experts as well, I am throwing it here as well.. I am having a table
which represents entities... User can upload entities(pics, videos etc).. i
want that no entity overwrite the other, but my entities can be on multiple
servers.. so i can't check the file system for the save name of the entity.
I need to refer to the table to see the entity_name... later on i use the
name as unique id.. here is the code that does the trick..

$result = $this->Entity->findByEntityUid($newfile);

        if (isset($result)) {
        $filenumber = 0;
        $filesuffix = '';
        $fileparts = explode('.', $newfile);
        $fileext = '.' . array_pop($fileparts);
        $filebase = implode('.', $fileparts);

            do {
                $filenumber++;
                $filesuffix = '-' . $filenumber;
                $entity_uid = $filebase . $filesuffix;
                $newfile = $entity_uid . $fileext;
            } while ($this->Entity->findByEntityUid($entity_uid));


But i am worried that this code is not thread safe... Can some one suggest
me that how to go about this problem? More over i want to use the same
entity uid as a primary key to the table so more worries come in when i
think that duplicate enteries can come in because of the code that is not
thread safe.. Please help..

-- 
Thanks & Regards,
Novice.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to