Using set() with PEAR2

Hi,
could you help to specify other criteria than ID when using $util->set() function, for example, I would like to set quota for a hotspot user using its name and not his ID (*5), thanks !!

$util->set(
5,
array(
‘limit-uptime’ => $_GET[‘quota’]
)
);

If the menu accepts names, you can just use it right there in place of the number, e.g.

$util->set(
'myquota',
array(
'limit-uptime' => $_GET['quota']
)
);

will look for an item named “myquota”.

If the item name contains a comma or matches the name of a function in PHP (and you don’t want to call the function), then you could instead pass a query. Under the hood, this will get the IDs matching the query, and will use them in the set, e.g.

$util->set(
RouterOS\Query::where('name', 'myquota'),
array(
'limit-uptime' => $_GET['quota']
)
);