Coder Social home page Coder Social logo

Comments (2)

erkutcin avatar erkutcin commented on June 3, 2024

i am trying to save attendance in database but i get this error can someone help me err1 err2 ?

Hi Aminechouchene98, i made all updates. But i am still not able to retrieve the datas. Could you advise me how did you do it? Thanks in advance

from zklibrary.

IncubuzzCC avatar IncubuzzCC commented on June 3, 2024

Hi erkutcin ,
This likely seems to be a database issue on your end, and not a device issue with the library.

In my case the uid returns the position the user record is stored in the device while id is the actual user id.
In your case it looks like yours is storing a consecutive id in the uid field and the user id in the id field.
Therefore thw data structure may slightly vary across devices.

As long as you do not clear attendance records the device by using the clearAttendance() function, the device will give you the same data plus the new attendance records.
If you clear the attendance records, which you probably should every once in a while to keep the download from becoming slow,

We worked around this by creating a combined primary key (or you could use a unique index) over the user id and the date time field.

CREATE TABLE ``deviceusers` (
  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(75) COLLATE utf8mb4_unicode_ci NOT NULL,
  `synctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `fetched` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
);

CREATE TABLE `deviceregs` (
  `deviceuser_id` smallint(5) unsigned NOT NULL,
  `time` datetime NOT NULL,
  `fetched` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`deviceuser_id`,`time`),
  CONSTRAINT `deviceregs_deviceuser_id_foreign` FOREIGN KEY (`deviceuser_id`) REFERENCES `deviceusers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);

This way you could use INSERT IGNORE or capture inserts that fail due to duplication.

I hope this helps.

Sample device attendance:

[23] => Array([0] => 29, [1] => 3, [2] => 0, [3] => 2022-12-09 19:02:00)
[24] => Array([0] => 9, [1] => 9, [2] => 0, [3] => 2022-12-10 07:39:07)
[25] => Array([0] => 163, [1] => 162, [2] => 0, [3] => 2022-12-10 07:41:35)

Sample device users:

[9] => Array([0] => 9, [1] => Josef, [2] => 0, [3] => )
[29] => Array([0] => 3, [1] => Fred, [2] => 14, [3] => 696910)
[163] => Array([0] => 162, [1] => Bernard, [2] => 0, [3] => )

from zklibrary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.