You need to first do a “print”, and get the ID of the entry you want to remove, and only then pass that ID in the remove’s “numbers” argument (same as your second example, but with the ID instead of “0”).
First stop, I must note that despite the name, having PEAR2 itself is not required.
The difference is in syntax, convenience features (many “small” ones, too many to just enumerate; and I have more in store for the upcoming version…) and support for shell-like syntax, so you don’t need to know the API protocol in details.
For example, with that client, an equivalent of your code would be:
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b3.phar';
$ip_host=$_POST['ip-host'];
$client = new RouterOS\Client('1.1.1.1', 'xxxxxx', 'xxxxxx');
$id = $client->sendSync(
new RouterOS\Request('/ip hotspot ip-binding print .proplist=.id', RouterOS\Query::where('address', $ip_host))
)->getArgument('.id');
$removeRequest = new RouterOS\Request('/ip hotspot ip-binding remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
And in the upcoming version (scheduled to be released in a week or so…*), it would be even easier, like:
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar';
$ip_host=$_POST['ip-host'];
$client = new RouterOS\Client('1.1.1.1', 'xxxxxx', 'xxxxxx');
$util = new RouterOS\Util($client);
$util->changeMenu('/ip hotspot ip-binding');
$util->remove(0);//If you know the exact position
$util->remove(RouterOS\Query::where('address', $ip_host));//If we're talking an exact equivalent to the above
1-)
require_once ‘PEAR2_Net_RouterOS-1.0.0b3.phar’;
Hi my problem php phar load class error..
and
2-)
$util->remove(0);//If you know the exact position
$util->remove(RouterOS\Query::where(‘address’, $ip_host));//If we’re talking an exact equivalent to the above
or remove change disable success ?
$util->disable(0);//If you know the exact position
$util->disable(RouterOS\Query::where(‘address’, $ip_host));//If we’re talking an exact equivalent to the above
1-)
require_once ‘PEAR2_Net_RouterOS-1.0.0b3.phar’;
Hi my problem php phar load class error..
Have you actually downloaded that file? You’ve probably downloaded the “b4.phar”, in which case, it should go without saying that you must replace
require_once 'PEAR2_Net_RouterOS-1.0.0b3.phar';
with
require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar';
And also… do you have PHP 5.3.0 or later? If you are not sure, create a new PHP file with
<?php phpinfo(); ?>
and see what it says at the top.
2-)
$util->remove(0);//If you know the exact position
$util->remove(RouterOS\Query::where(‘address’, $ip_host));//If we’re talking an exact equivalent to the above
or remove change disable success ?
$util->disable(0);//If you know the exact position
$util->disable(RouterOS\Query::where(‘address’, $ip_host));//If we’re talking an exact equivalent to the above
If you mean “Can you change ‘remove’ to ‘disable’ to disable matching items instead of removing them” - Yes.