vodvud / php_zklib

GNU General Public License v2.0
24 stars 19 forks source link

How to insert all data record to database #8

Closed yudis2 closed 5 years ago

yudis2 commented 5 years ago

I was try to download and receive all record and its work when its code are echo, but not to insert into database.. can you help me ?

yudis2 commented 5 years ago

1

yudis2 commented 5 years ago

1

vodvud commented 5 years ago

Hi @yudisdwi26 I see error in your code, remove the row foreach ($users as $uItem) { above this one foreach ($attendance as $attItem) {

yudis2 commented 5 years ago

filter

how to filter sign when 8.00 AM is sign in and 5.00 pm sign out.. ? please help sir.. thanks

vodvud commented 5 years ago

@yudisdwi26 Sorry, but this is question not about this library. Please use google for that next time!

Example for your situation

DATEPART(hour, `sign`) BETWEEN 8 AND 17
yudis2 commented 5 years ago

sorry that's not what i meant ... can when downloading data record. one date but two times one as sign in and one as sign out.. $Date = date("Y-m-d", strtotime($attItem['timestamp'])); $Sign_in = date("H:i:s", strtotime($attItem['timestamp']));

output : as example : 1 | Didi | 2019/03/25 | 08:00:00 1 | Didi | 2019/03/25 | 17:00:00

but can you help me to make format : 1 | Didi | 2019/03/25 | 08:00:00 | 17:00:00.

Im sory talking to you again. because i have use google and many source code but not working..

vodvud commented 5 years ago

@yudisdwi26 Hi! You have answer into your question.

create a table attendance with structure like this id | uid | date | time_in | time_out

Then do select by date before insert or update

SELECT `id` FROM `attendance` WHERE `date`=:date;

if select returned id do update time_out

UPDATE `attendance` SET `time_out`=:time WHERE `id`=:id;

else insert without time_out

INSERT INTO `attendance` (`uid`, `date`, `time_in`, `time_out`) VALUES (:uid, :date, :time, '00:00:00');

Will be one row per day like you want.

yudis2 commented 5 years ago

Thanks you for your attention.. ask last my question sir, can you help to make its when i search data only one day record or only one date

yudis2 commented 5 years ago

ask

yudis2 commented 5 years ago

ask

vodvud commented 5 years ago

Hi @yudisdwi26

You did some mistake in your code, because in DB should not be more then one row per day. Please review your code and fix by yourself.

Thank you!

yudis2 commented 5 years ago

is there primary key or index in table field ? and in realtime someone ussually do more than one finger in time... therefore make it more than one row per day... big thanks for your answer...

vodvud commented 5 years ago

Yes, id is primary key, auto increment. But if you don't use it, you can update by date field.

yudis2 commented 5 years ago

Hi! i was try to review my code from you.. in a realtime someone can be finger more than one and it makes record twice.. im really hope you can help to solve this... 1 Sory I type in bahasa.. tanggal is date, and absensi is attendance.. Thanks bro!

yudis2 commented 5 years ago

when i try to unique for date.. its work for one day one row but other ID is nor inserted..

dalersingh commented 5 years ago

@yudisdwi26 This issue is not related to ZK library code, there are logical problems in your coding, which are very basic. Unfortunately, we try our best to answer or support questions related to ZK library here. It would not be possible for us to fix or explain basic programming logic.

May be you can work a bit more on your logical design or take in-person help from someone senior around you in relation to this issue.

I hope you understand