PDA

View Full Version : Web-Site Help: Viewing the Last Stage


Dutch
02-28-2014, 03:42 PM
I am having trouble in FOF7 doing a query where I can display last week's games.

In the Universe_Info.csv file, there is a reference to the current stage name, but not the last stage name.

If anybody is willing to help me solve this, I would appreciate it.

With dbupdater, I could simply write a query that would state, "WHERE week=(current_week - 1) because "current_week" was an integer. In the Universe_info.csv, the current week is written as "Ex. Season Week #2" (for example).

I built a "stage_info" table and I can join that table to the universe_info table on "Ex. Season Week #2" and then go back one in the "stage_info.stage_id" column, but with no additional relationships that doesn't really do me any good.

Is there a good way already built in that I need to look at?

Ben E Lou
02-28-2014, 03:51 PM
Right now it's just a two-part process. Find the year by using select max(year) from fof7_game_information. Then I have a translate_weeks table (sounds similar to your stage_info one) that I join to from fof7_game_information to give me the week of the first gameid that matches that year. That gives me the week number and I can use that to connect to the performances from that week.

Dutch
02-28-2014, 03:54 PM
I started to look at that the other day actually. The benefit of the game_id was that they are all static year to year (except 2003 for some reason), I just wasn't sure how I was going to use that.

But if you have it working that way, then I'll certainly follow suit. Thanks, Ben.

aston217
02-28-2014, 04:37 PM
I think this can be accomplished without a translate table in the DB.


...WHERE week = change_stage($current_stage_name, -1)...

function change_stage($current_stage_name, $n) {
$lookup_stage_names = array(
'0' => 'Pre_Staff_Draft',
'1' => '...' //etc.
);

$key = array_search($current_stage_name, $lookup_stage_names);

if ($key == false) { //default value
$key = $current_stage;
}


return $key;
}

Dutch
03-02-2014, 02:39 PM
Damn, that's a great way to do it, I'm just not that skilled yet to be writing functions. At least, I certainly am not thinking 'function' at all, but that looks like something I need to develop. The benefit would that I wouldn't need to 'cheat' and add fields to the db, but that's what I ultimately did.

So now my 'stage_info' table shows the relationship to the stage before and after it for easy reference later on.

So, my stage_info table looks like this

stage_id
game_id (primary key)
stage_name
last_stage_name
next_stage_name

Where the last three columns have a name that equals the universe_info.value_round_position's lone VARCHAR entry...which is the name of the current stage.

Now I can relate the value_round_position to the next_game_stage value and I get last week's results.

I feel like I went around the Earth to get from Tampa to Orlando, but fuck it, I'm there now. :)

Thanks for the help, guys.