pear2/Net_RouterOS

$util->count() use query can't return correct value

ziyifeihu opened this issue · 5 comments

when I test the count use query,
$count = $util->count(RouterOS\Query::where('disabled','true'));

it will return all value.

Which menu and RouterOS version is that?

Test Menu: /ip arp, or /ip address
RouterOS Version: v6.28
Device: 951G-2HnD

Probably a bug with that older RouterOS version... With v6.41 on a 951Ui-2HnD, I tried the following code:

<?php

use PEAR2\Net\RouterOS;

require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar';

$util = new RouterOS\Util(new RouterOS\Client('192.168.88.1', 'admin'));

$util->setMenu('/ip address');
var_dump($util->count());
var_dump($util->count(RouterOS\Query::where('disabled', 'false')));
var_dump($util->count(RouterOS\Query::where('disabled', 'true')));
var_dump($util->count(RouterOS\Query::where('address', '192.168.88.1/24')));

$util->setMenu('/ip arp');
var_dump($util->count());
var_dump($util->count(RouterOS\Query::where('disabled', 'false')));
var_dump($util->count(RouterOS\Query::where('disabled', 'true')));
var_dump($util->count(RouterOS\Query::where('address', '192.168.88.254')));

And from the command line, I get (as expected):

D:\Vasko\WEB\php_test\test.php:10:
int(2)
D:\Vasko\WEB\php_test\test.php:11:
int(2)
D:\Vasko\WEB\php_test\test.php:12:
int(0)
D:\Vasko\WEB\php_test\test.php:13:
int(1)
D:\Vasko\WEB\php_test\test.php:16:
int(3)
D:\Vasko\WEB\php_test\test.php:17:
int(3)
D:\Vasko\WEB\php_test\test.php:18:
int(0)
D:\Vasko\WEB\php_test\test.php:19:
int(1)

Got it! Many thanks!!!

Wait... Was it a version problem or what?

I mean, I could also see the original problem having been a problem with your code, which you now figured thanks to the example...