Page 1 of 1

upgrade.php in NAFLM/OBBLM

Posted: Tue Aug 27, 2019 2:00 pm
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

Re: upgrade.php in NAFLM/OBBLM

Posted: Wed Aug 28, 2019 10:22 am
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

Re: upgrade.php in NAFLM/OBBLM

Posted: Thu Aug 29, 2019 4:50 am
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,

Re: upgrade.php in NAFLM/OBBLM

Posted: Fri Aug 30, 2019 4:42 am
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,

Re: upgrade.php in NAFLM/OBBLM

Posted: Fri Aug 30, 2019 9:14 am
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.

Re: upgrade.php in NAFLM/OBBLM

Posted: Fri Aug 30, 2019 1:02 pm
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,

Re: upgrade.php in NAFLM/OBBLM

Posted: Sat Aug 31, 2019 6:15 pm
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,