Forum BigDB DatabaseArray.Clear() issues?

Discussion and help relating to the PlayerIO database solution, BigDB.

DatabaseArray.Clear() issues?

Postby markloika » July 14th, 2010, 9:38 am

I have the following code:

Code: Select all
PlayerIO.BigDB.LoadOrCreate("PUD", connectedPlayer.Name, delegate(DatabaseObject savedData)
{
    trace("loaded saved data");
    DatabaseArray savedRequests = savedData.GetArray("r");
    if (savedRequests == null)
    {
        savedRequests = new DatabaseArray();
        savedData.Set("r", savedRequests);
        trace("saved data was null");
                               
    }

    foreach (DatabaseObject request in requests)
    {
        DatabaseObject requestToSave = new DatabaseObject();
        requestToSave.Set("t", request.GetString("t"));
        requestToSave.Set("n", request.GetString("n"));
        savedRequests.Add(requestToSave);
        trace("added request");
    }

    connectedPlayer.Send("req");
    trace("sent notification of request");

    requests.Clear();
    trace("cleared requests");
    result.Save();
    trace("saved result");
    savedData.Save();
    trace("saved saveData");
});


I got tired of typing Console.WriteLine every time, so I made a function called trace. Anyway, everything traces up to the "sent notification of request", the "cleared requests" never traces, and it doesn't happen (or at least it doesn't save it if it does happen) because when I check the table in the admin, I still see the array that I'm trying to clear. Am I doing something wrong?

On a side note, I think I found a bug. In the for each loop, if I do:

Code: Select all
savedRequests.Add(request);


I get an error about circular references. requests and savedRequests are both DatabaseArrays, but requests is in a different table. It would seem this is odd behavior to consider it a circular reference if it's in a different table. I was expecting that it would just replicate the DatabaseObject and put it in the new DatabaseArray. Maybe that would be illogical, it's just what I was expecting, so maybe this isn't even a bug.
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: DatabaseArray.Clear() issues?

Postby Oliver » July 26th, 2010, 12:07 pm

Hey,

Sorry for the late reply!

So, it seems that your code snippet is not complete -- Where does the "requests" and "result" variables come from ?

Is it possible to send me the complete source code? (my name @ this domain .com)

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: DatabaseArray.Clear() issues?

Postby markloika » July 27th, 2010, 4:16 am

Hi Oliver,

Unfortunately, I no longer have that code. I'm doing things a little differently since posting that. I can say with certainty though, that the requests and result variables were defined and not null.

Due to time constraints, I've had to cut a few features out of my game. The main two features that are being cut are adding players as friends, and inviting a friend to a game. I would have really liked to have those features, and had they been easier to implement I would have had them. I'll have to add those features in a future version of the game.

Regards,
Mark
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: DatabaseArray.Clear() issues?

Postby Oliver » July 27th, 2010, 9:59 am

Hey Mark,

Okay -- Thanks. Let me know if you have further issues: I promise to answer promptly!

Also; Can we see the game ? :D

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: DatabaseArray.Clear() issues?

Postby markloika » July 27th, 2010, 10:52 am

Hi Oliver,

Thanks for your help, I appreciate it. I'm planning on having a (very) closed beta soon, and I was already planning to invite you and Chris, so stay tuned!

Cheers,
Mark
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am


Return to BigDB



cron