kamshory / ZKLibrary

ZKLibrary is PHP library for reading and writing data to attendance device using UDP protocol. This library useful to comunicate between web server and attendance device directly without addition program. This library is implemented in the form of class. So that you can create an object and use it functions.
GNU General Public License v2.0
194 stars 176 forks source link

Disabling method before PHP processing #45

Open todpale opened 5 years ago

todpale commented 5 years ago

Hello! Thank you very much for so helpful library! I have a question connecting with methods calling. I get the attendances and user data for variables. Can I enable and disconnect the device after this and then make the PHP array processing? For example, I have this code now:

       //connection here
        $data = $zk->getAttendance();
    $users = $zk->getUser();

    foreach($data as $key=>$value){
                 //processing        
         }

        $zk->enableDevice();
    $zk->disconnect();

I want to do like this:

        //connection here
        $data = $zk->getAttendance();
    $users = $zk->getUser();
        $zk->enableDevice();
    $zk->disconnect();

    foreach($data as $key=>$value){
                 //processing        
         }

Is it real? I would test this idea, but I work with frequently used gadget and don't want to interrupt its process :)

kamshory commented 5 years ago

$zk->disableDevice(); and $zk->enableDevice(); just to prevent device not responding when library read data from it. By invoke $zk->disableDevice(), user will wait until reading process finish. Because all user data have been read with $users = $zk->getUser(), you can disconnect before you process the data. User data have been stored on variable $user.

todpale commented 5 years ago

@kamshory thanks a lot!