Community discussions

MikroTik App
 
binhorp
newbie
Topic Author
Posts: 39
Joined: Wed Mar 05, 2008 4:40 pm

Problem when trying to move simple queues

Fri Jan 24, 2014 6:05 pm

Good afternoon everyone, I am trying to move a queue to first position through php api, but sometimes the script removes all queues rather than move it, someone could give me a hand with this script? routeros version routeros 5.2x
very grateful to all!

$API->write('/queue/simple/getall', false);
$API->write('?name=' . $name);
$ARRAY = $API->read();
$ARRAY = $ARRAY[0];
$API->write('/queue/simple/move', false);
$API->write('=.id=' . $ARRAY['.id'],false);
$API->write('=destination=*0',true);
$ARRAY = $API->read();
$API->disconnect();
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Problem when trying to move simple queues

Fri Jan 24, 2014 8:07 pm

The ID of the first item probably isn't "*0". That is, you'd need to take that out of the print too. In the "/queue/simple" menu in particular, you can also target by name BTW.

A move command should never be removing anything though.
 
binhorp
newbie
Topic Author
Posts: 39
Joined: Wed Mar 05, 2008 4:40 pm

Re: Problem when trying to move simple queues

Sat Jan 25, 2014 12:08 am

Thank you friend, you could help me with this problem, I need to move a queue to the top, how would the script below?
$API->write('/queue/simple/getall', false);
$API->write('?name=' . $name);
$ARRAY = $API->read();
$ARRAY = $ARRAY[0];
$API->write('/queue/simple/move', false);
$API->write('=.id=' . $ARRAY['.id'],false);
$API->write('=destination=*0',true);
$ARRAY = $API->read();
$API->disconnect();
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Problem when trying to move simple queues

Sat Jan 25, 2014 12:14 am

If you don't know the name of the first queue in advance, you need to get it with a print.

After you have that, you just supply it as the "destination" argument.

In terms of actual code... I feel really awkward working with that client, especially when with mine, it's simplified to
$util->changeMenu('/queue/simple');
$util->move($name, 0);
(see this for a full code sample)


I guess with that, it would something among the lines of
$API->write('/queue/simple/getall', false);
$ARRAY = $API->read();
$ARRAY = $ARRAY[0];
$API->write('/queue/simple/move', false);
$API->write('=.id=' . $name,false);
$API->write('=destination=' . $ARRAY['.id'],true);
$ARRAY = $API->read();
$API->disconnect();