mercredi 3 octobre 2018

Can't save UUID field in PHP script iteration, Laravel, Postgres

I'm trying to fill already existing models with UUID. And every time it says that UUID is not unique! What a bloody hell! )))

  function unique_guid($model){
        $guid = com_create_guid();
        $table = $model->table;
        $db_table = Db::table($table);
        $req = $db_table->where("guid", strval($guid));
        $instance = $req->first();

        if(is_object($instance)){
            $guid = unique_guid($model);
            return;
        }else{
            try{
                $model->guid = $guid;
                $model->save();
                sleep(2);
                return $guid;
            }catch(PDOException $Exception){
                $guid = unique_guid($model);
            }

        }
    } 

It keeps circling in try/catch block and telling me that it is not unique, i checked and there is no record with genereted UUID. Also - it brokes at third-fourth iteration, and if i add sleep(5) it works longer - 10 iteration and then brokes. What in the world can it be? Laravel 5.5, Postgres 9



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire