upgrade.php in NAFLM/OBBLM

However you play online - Java, Vassal, Email, Cyanide etc - talk about it here.
This is also the place for discussing the various tools for managing leagues, teams and so on.

Moderator: TFF Mods

Post Reply
spugnoid
Rookie
Rookie
Posts: 13
Joined: Tue Sep 11, 2018 12:11 am

upgrade.php in NAFLM/OBBLM

Post by spugnoid »

Does anyone know how to use upgrade.php to create new colums in database tables?

I have added the ability for the commish to change FF for redrafting and now I'm adding Seasons Played and Wants to Retire but I'd like to auto-create new columns. I can do it on a new install with install.php but not as an upgrade.

Thanks

Reason: ''
Tim
Da Tulip Champ II
Posts: 3458
Joined: Wed Oct 16, 2002 4:18 pm
Location: Heidelberg, Germany
Contact:

Re: upgrade.php in NAFLM/OBBLM

Post by Tim »

Can‘t look into it in detail right now, but theoretically you just need to post an ALTER TABLE SQL statement instead of the CREATE TABLE used in install.php

Reason: ''
Image
"In NUFFLE we trust!" - Retired Inquisitor of Nuffle.
Father of the Halfling Scribe
Admin of the Kurpfalz Cup
spugnoid
Rookie
Rookie
Posts: 13
Joined: Tue Sep 11, 2018 12:11 am

Re: upgrade.php in NAFLM/OBBLM

Post by spugnoid »

Ok, I've created an update.php file and have successfully created the new columns. If this is going to be useful, it should run from a script.

I've found out how to increment a value for 'seasons played', but I am struggling to get it to display on the team roster page. I've gone through most of the files and I sure wish it was documented/commented. The team management box now has a tool for incrementing the value and I have another tool for flagging 'wants to retire'. I will add admin tools later to undo these changes for when the coaches mess it up. I just don't want coaches to be able to fiddle with those values without an admin involved.

The redraft FF correction works well so that's encouraging, but it was much easier to implement than the seasons played/wants to retire ability.

I've also got some ideas (after staring at the files in /lib for hours on end) on how to better allow rostering star players, but that is for another day.

I'll try to keep progress updates going.

Cheers,

Reason: ''
spugnoid
Rookie
Rookie
Posts: 13
Joined: Tue Sep 11, 2018 12:11 am

Re: upgrade.php in NAFLM/OBBLM

Post by spugnoid »

Well, I have new columns displayed on the team roster page. I can put data into them from the team management box dropdown tools. I can display any piece of data I want in those columns, except, I can't figure out how to call the data from the new columns in the table.

I've tried a lot of stuff. If anyone has any ideas, I'm all ears.

Cheers,

Reason: ''
User avatar
Vanguard
Super Star
Super Star
Posts: 922
Joined: Sun Jun 08, 2008 8:27 am
Location: Glasgow
Contact:

Re: upgrade.php in NAFLM/OBBLM

Post by Vanguard »

So you have the new field in the tables, can see it in the database and populate it, but are having trouble reading it into a OBBLM page?
The various classes have procedures that run queries against the database with preset fields specified, so I think you'll need to edit the script. Since this is for players, you'd be looking in the player class somewhere. Athough, the class may just be calling a stored procedure in the database, so that might be where the change is required? Although the calling function will need updated to handle the additional field too.
Apologies for being a little hazy ont he details, been a while since I looked.

Reason: ''
spugnoid
Rookie
Rookie
Posts: 13
Joined: Tue Sep 11, 2018 12:11 am

Re: upgrade.php in NAFLM/OBBLM

Post by spugnoid »

That about sums it up.

If I tell my code to put my table data into the roster, nothing happens. If I change it to look at any other data, such as player name, it shows up in the seasons played column. So all I'm missing is the part where I tell the code to pull data from that column.

I'll keep looking.

Thanks,

Reason: ''
spugnoid
Rookie
Rookie
Posts: 13
Joined: Tue Sep 11, 2018 12:11 am

Re: upgrade.php in NAFLM/OBBLM

Post by spugnoid »

Well, I've got it working. It's a bit messy in the code but my SQL and PHP knowledge is minuscule.

http://hbba.obblm.com/naflm-master is my test site. You can login with usr/pwd coacha/coacha or coachb/coachb.

I did have one instance where a player suddenly turned into a journeyman and I had to manually undo it in the database. I have not touched any of that code so I assume it was a freak thing. If you reproduce it, let me know.

https://github.com/spugnoid/naflm takes you to my fork. I'm learning how to use Git so its also a bit messy as I haven't bothered to read any documentation yet.

Please note that my fork has Spike 6 data incorporated and allows teams to roster Star Players since my league wanted to. My method was to add stars directly to races and prefix with an '*'. It works fine as long as you also induce that same star after each match so you can update their stats. Don't update the stats for stars on the normal roster row as it will not work. You'll earn them SPP they can never spend and it won't track star stats globally, just for your team. Inducing them allows the stats behaviour to be normal. Someday I'll look at a better way but working with almost zero documentation in the OBBLM code hasn't been fun.

Next project is to allow Admin to remove MNG but it's not going to be easy because of the way that flag is set.

Cheers,

Reason: ''
Post Reply