vodvud / php_zklib

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

Insert Not Working After CardNo Update #19

Closed aice09 closed 4 years ago

aice09 commented 4 years ago

The code in the example.php is working after update:

$zk->setUser(1, '211', 'Carl', '5555', ZK\Util::LEVEL_USER, '0007909321');
$zk->setUser(2, '2', 'Admin', '0927', ZK\Util::LEVEL_ADMIN,'0008209349');

But when I update the following code in https://github.com/aice09/php_zklib-1/blob/master/sync.php

Not Working

$zk->setUser(
                    $user['uid'],
                    $user['userid'],
                    $user['name'],                   
                    $user['cardno'],
                    $user['role'],
                    $user['password']
                );

Working but shuffled

$zk->setUser(
                    $user['userid'],
                    $user['name'],  
                    $user['cardno'],
                    $user['uid'],   
                    $user['role'],             
                    $user['password']
                );

Not Working base from zklib/src/User.php public function set and example

$zk->setUser(
                    $user['uid'], 
                    $user['userid'],
                    $user['name'],  
                    $user['password'],  
                    $user['role'],             
                    $user['cardno']
                );

What is the best way to setusers?

vodvud commented 4 years ago

Correct format is

/**
 * @param int $uid Unique ID (max 65535)
 * @param int|string $userid ID in DB (same like $uid, max length = 9, only numbers - depends device setting)
 * @param string $name (max length = 24)
 * @param int|string $password (max length = 8, only numbers - depends device setting)
 * @param int $role Default Util::LEVEL_USER
 * @param int $cardno Default 0 (max length = 10, only numbers)
 */
$zk->setUser($uid, $userid, $name, $password, $role, $cardno);

See https://github.com/vodvud/php_zklib/blob/e277b4bbe3bc93d11d2aacb773bf188770d78fd8/zklib/ZKLib.php#L223-L237

vodvud commented 4 years ago

Check your parameters before send, maybe you got incorrect data, type or size.

bezhanSalleh commented 4 years ago

It works perfectly, I tested it on iFace 702. @vodvud You can go ahead and close this issue.

vodvud commented 4 years ago

Ok, this issue closed.