Forum Moderators: coopster
I have an SQL script to insert daily work records in a database.
However, due to the fact that a worker can change the employer from day to day, those records are subject to changes. So I thought PHP would come in handy to address those changes in inserting the records since It allows to write a function that would be run on the command line, passing arguments therebyin, which would avoid me to every time adapt the SQL script whenever the employer comes to change.
Here's how the SQL script looks like:
INSERT INTO work VALUES
(
NULL, CURDATE() , DAYNAME(CURDATE()),'DMX','07:00:00','17:00:00',(finish-start),
'1:00:00',( duration - break ),10.35,CAST(HOUR(net_duration)+MINUTE(net_duration)/60 AS DECIMAL(4,2))*hourly_pay,
'0:00',0,0,daily_pay
);
table `work` columns are:
work_id,
date,
day,
company
start,
finish,
duration,
break,
net_duration,
hourly_pay,
daily_pay,
extratime,
extratime_rate,
extratime_pay,
total_daily_pay
When an employer changes, column values that must change are:
- company,
- start and finish(every company has its own work schedule),
- break (not every company offers same break length),
- hourly_pay (notevery company offers employees same wages),
- extratime (some companies allow overtime),
- extratime_rate(whenever there's overtime, the hourly rate depends on the company),
** The duration is just the difference between the finish time and the starting time whereas the net_duration is the difference between the duration and the break time.
So, i'd like a help of a PHP function that would be run on the command line to simplify the editing of SQL file every time there's any change, a function like:
work($company, $start, $finish, $break, $hourly_pay, $extratime, $extratime_rate) to be called on the command-line.
Also which configuration should I make to make PHP be runnable on the command line?
Thank you guys
$_SERVER['argv'] and $_SERVER['argc'] variables.