Common base class for collector and querybuilder

package midcom

 Methods

add_constraint (string $field, string $operator, mixed $value)

Add a constraint to the query.

Parameters

$field

stringThe name of the MgdSchema property to query against.

$operator

stringThe operator to use for the constraint, currently supported are <, <=, =, <>, >=, >, LIKE. LIKE uses the percent sign ('%') as a wildcard character.

$value

mixedThe value to compare against. It should be of the same type then the queried property.

Returns

booleanIndicating success.

add_constraint_with_property (string $field, string $operator, string $compare_field)

Add a constraint against another DB column to the query.

Parameters

$field

stringThe name of the MgdSchema property to query against.

$operator

stringThe operator to use for the constraint, currently supported are <, <=, =, <>, >=, >, LIKE. LIKE uses the percent sign ('%') as a wildcard character.

$compare_field

stringThe field to compare against.

Returns

booleanIndicating success.

add_order (string $field, string $direction)

Add an ordering constraint to the query builder.

Parameters

$field

stringThe name of the MgdSchema property to query against.

$direction

stringOne of 'ASC' or 'DESC' indicating ascending or descending ordering. The default is 'ASC'.

Returns

booleanIndicating success.

begin_group (string $operator)

Creates a new logical group within the query.

They are set in parentheses in the final SQL and will thus be evaluated with precedence over the normal out-of-group constraints.

While the call lets you decide whether all constraints within the group are AND'ed or OR'ed, only OR constraints make logically sense in this context, which is why this proxy function sets 'OR' as the default operator.

Parameters

$operator

stringOne of 'OR' or 'AND' denoting the logical operation with which all constraints in the group are concatenated.

count ()

count_unchecked ()

end_group ()

Ends a group previously started with begin_group().

execute ()

get_classname ()

Get the DBA class we're currently working on

set_limit (int $limit)

Limits the resultset to contain at most the specified number of records.

Set the limit to zero to retrieve all available records.

Parameters

$limit

intThe maximum number of records in the resultset.

set_offset (int $offset)

Sets the offset of the first record to retrieve.

This is a zero based index, so if you want to retrieve from the very first record, the correct offset would be zero, not one.

Parameters

$offset

intThe record number to start with.

_add_visibility_checks ()

_reset ()

Resets some internal variables for re-execute

 Properties

 

boolean $hide_invisible

Set this element to true to hide all items which are currently invisible according to the approval/scheduling settings made using Metadata.

This must be set before executing the query.

NOTE: Approval checks not implemented in collector yet

Be aware, that this setting will currently not use the QB to filter the objects accordingly, since there is no way yet to filter against parameters. This will mean some performance impact.

 

int $_constraint_count

This is an internal count which is incremented by one each time a constraint is added.

It is used to emit a warning if no constraints have been added to the QB during execution.

 

int $_denied

The number of objects for which access was denied.

This is especially useful for reimplementations of functions like mgd_get_article_by_name which must use the QB in the first place.

 

int $_groups

The number of groups open
 

int $_limit

The number of records to return to the client at most.
 

int $_offset

The offset of the first record the client wants to have available.
 

int $_orders

The ordering instructions used for this query
 

object $_query

The query backend, should be set in constructor.

Currently collector or querybuilder

 

string $_real_class

This helper holds the type that the application expects to retrieve from this instance.
 

boolean $_visibility_checks_added

Flag that tracks whether deleted visibility check have already been added
 

int $count

The number of records found by the last execute() run.

This is -1 as long as no query has been executed. This member is read-only.