|
|
|
@ -23,6 +23,7 @@ Basic example, analogue via command line is `/ip address print`: |
|
|
|
|
|
|
|
```php |
|
|
|
use \RouterOS\Client; |
|
|
|
use \RouterOS\Query; |
|
|
|
|
|
|
|
// Initiate client with config object |
|
|
|
$client = new Client([ |
|
|
|
@ -31,9 +32,25 @@ $client = new Client([ |
|
|
|
'pass' => 'admin' |
|
|
|
]); |
|
|
|
|
|
|
|
// Send query to RouterOS and read response from it |
|
|
|
$response = $client->query('/ip/address/print')->read(); |
|
|
|
// Create "where" Query object for RouterOS |
|
|
|
$query = |
|
|
|
(new Query('/ip/hotspot/ip-binding/print')) |
|
|
|
->where('mac-address', '00:00:00:00:40:29'); |
|
|
|
|
|
|
|
// Send query and read response from RouterOS |
|
|
|
$user = $client->query($query)->read(); |
|
|
|
|
|
|
|
var_dump($response); |
|
|
|
|
|
|
|
// Send "equal" query |
|
|
|
$query = |
|
|
|
(new Query('/ip/hotspot/ip-binding/add')) |
|
|
|
->equal('mac-address', '00:00:00:00:40:29') |
|
|
|
->equal('type', 'bypassed') |
|
|
|
->equal('comment', 'testcomment'); |
|
|
|
|
|
|
|
// Send query and read response from RouterOS (ordinary answer to update/create/delete queries has empty body) |
|
|
|
$user = $client->query($query)->read(); |
|
|
|
``` |
|
|
|
|
|
|
|
Examples with "where" conditions, "operations" and "tag": |
|
|
|
@ -42,7 +59,13 @@ Examples with "where" conditions, "operations" and "tag": |
|
|
|
use \RouterOS\Query; |
|
|
|
|
|
|
|
/** |
|
|
|
* Send advanced query with parameters to RouterOS |
|
|
|
* Simple "where" query will be generated by default |
|
|
|
*/ |
|
|
|
|
|
|
|
$client->query('/ip/address/print')->read(); |
|
|
|
|
|
|
|
/** |
|
|
|
* Send advanced "where" query with parameters to RouterOS |
|
|
|
*/ |
|
|
|
|
|
|
|
// If only one "where" condition |
|
|
|
@ -58,6 +81,12 @@ $client->query('/interface/print', [ |
|
|
|
* Or in OOP style |
|
|
|
*/ |
|
|
|
|
|
|
|
// If you need create query for "create/update/delete" operations |
|
|
|
$query = new Query('/ip/hotspot/ip-binding/add'); |
|
|
|
$query->equal('mac-address', '00:00:00:00:40:29'); |
|
|
|
$query->equal('type', 'bypassed'); |
|
|
|
$query->equal('comment', 'testcomment'); |
|
|
|
|
|
|
|
// If multiple "where" conditions and need merge (operation "|") results |
|
|
|
$query = new Query('/interface/print'); |
|
|
|
$query->where('type', 'ether'); |
|
|
|
|