Query.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
RouterOS API client implementation.
RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts. PHP version 5
Author
Vasil Rangelov  
Category
Net  
Copyright
2011 Vasil Rangelov  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  
Package
PEAR2_Net_RouterOS  
Version
1.0.0b4  

\PEAR2\Net\RouterOS\Query

Package: PEAR2_Net_RouterOS
Represents a query for RouterOS requests.
Author
Vasil Rangelov  
Category
Net  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  

Constants

>VConstant  ACTION_EXIST = ''
Checks if the property exists.
>VConstant  ACTION_NOT_EXIST = '-'
Checks if the property does not exist.
>VConstant  ACTION_EQUALS = '='
Checks if the property equals a certain value.
>VConstant  ACTION_LESS_THAN = '<'
Checks if the property is less than a certain value.
>VConstant  ACTION_GREATHER_THAN = '>'
Checks if the property is greather than a certain value.

Properties

>VPropertyprotectedarray $words = array()

An array of the words forming the query. Each value is an array with the first member being the predicate (action and name), and the second member being the value for the predicate.

Default valuearray()Details
Type
array

Methods

methodprivate__construct() : void

This class is not to be instantiated normally, but by static methods instead. Use {@link where()} to create an instance of it.

methodprivate_send(\PEAR2\Net\RouterOS\Communicator $com) : int

Sends the query over a communicator.

The only difference with the non private equivalent is that this one does not do locking.
Parameters
NameTypeDescription
$com\PEAR2\Net\RouterOS\Communicator

The communicator to send the query over.

Returns
TypeDescription
intThe number of bytes sent.
methodprotectedaddWhere(string $name, string $value, string $action) : \PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\Query

Adds a condition.

Parameters
NameTypeDescription
$namestring

The name of the property to test.

$valuestring

The value to test against. Not required for existence tests.

$actionstring

One of the ACTION_* constants. Describes the operation to perform.

Returns
TypeDescription
\PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\QueryThe query object.
Details
Fluent
This method is part of a fluent interface and will return the same instance  
methodpublicandWhere(string $name, string $value = null, string $action = self::ACTION_EXIST) : \PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\Query

Adds a condition in addition to the query.

Parameters
NameTypeDescription
$namestring

The name of the property to test.

$valuestring

The value to test against. Not required for existence tests.

$actionstring

One of the ACTION_* constants. Describes the operation to perform.

Returns
TypeDescription
\PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\QueryThe query object.
Details
Fluent
This method is part of a fluent interface and will return the same instance  
methodpublicnot() : \PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\Query

Negates the query.

Returns
TypeDescription
\PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\QueryThe query object.
Details
Fluent
This method is part of a fluent interface and will return the same instance  
methodpublicorWhere(string $name, string $value = null, string $action = self::ACTION_EXIST) : \PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\Query

Adds a condition as an alternative to the query.

Parameters
NameTypeDescription
$namestring

The name of the property to test.

$valuestring

The value to test against. Not required for existence tests.

$actionstring

One of the ACTION_* constants. Describes the operation to perform.

Returns
TypeDescription
\PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\QueryThe query object.
Details
Fluent
This method is part of a fluent interface and will return the same instance  
methodprotectedsanitizeAction(string $action) : string
static

Sanitizes the action of a condition.

Parameters
NameTypeDescription
$actionstring

The action to sanitize.

Returns
TypeDescription
stringThe sanitized action.
methodpublicsend(\PEAR2\Net\RouterOS\Communicator $com) : int

Sends the query over a communicator.

Parameters
NameTypeDescription
$com\PEAR2\Net\RouterOS\Communicator

The communicator to send the query over.

Returns
TypeDescription
intThe number of bytes sent.
methodpublicwhere(string $name, string $value = null, string $action = self::ACTION_EXIST) : \PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\Query
static

Creates a new query with an initial condition.

Parameters
NameTypeDescription
$namestring

The name of the property to test.

$valuestring

The value to test against. Not required for existence tests.

$actionstring

One of the ACTION_* constants. Describes the operation to perform.

Returns
TypeDescription
\PEAR2\Net\RouterOS\Query | \PEAR2\Net\RouterOS\QueryThe query object.
Details
Fluent
This method is part of a fluent interface and will return the same instance  
Documentation was generated by phpDocumentor 2.1.0-DEV .