class Query implements QueryInterface (View source)

Properties

protected $command
protected $commands

Methods

__construct(array $target = array(), array $commands = array())

Builds a query with the given $command on the given $target.

Add
add(array $updates, string $class, boolean $append = true)

Adds a relation in a link-list|set.

Alter
alter(string $class, string $attribute, string $value)

Alters an attribute of a class.

Alter
alterProperty(string $class, string $property, string $attribute, string $value)

Alters the $property of $class setting $sttribute to $value.

andWhere(string $condition, mixed $value = null)

Adds a where condition to the query.

between(string $key, string $left, string $right)

Converts a "normal" select into an index one.

mixed
create($class, $property = null, string $type = null, string $linked = null)

Executes a CREATE of a $class, or of the $property in the given $class if $property is specified.

Delete
delete(string $from)

Executes a DELETE SQL query on the given class (= $from).

mixed
drop(string $class, string $property = null)

Drops a $class, or the $property in the given $class if $property is specified.

fields(array $fields, boolean $append = true)

Sets the fields to query.

from(array $target, boolean $append = true)

Adds a from clause to the query.

getCommand()

Returns the internal command.

String
getRaw()

Returns the raw SQL query statement.

array
getTokens()

Returns the tokens associated to the current query.

Grant
grant(string $permission)

Converts the query into an GRANT with the given $permission.

Find
findReferences(string $rid, array $classes = array(), boolean $append = true)

Finds documents referencing the document with the given $rid.

mixed
in(array $in, boolean $append = true)

Sets the classes in which the query performs is operation.

index(string $property, string $type, string $class = null)

Creates a index

indexCount(string $indexName)

Count the elements of the index $indexName.

indexPut(string $indexName, string $key, string $rid)

Puts a new entry in the index $indexName with the given $key and $rid.

indexRemove(string $indexName, string $key, string $rid = null)

Removes the index $indexName with the given $key/$rid.

rebuild(string $indexName)

Rebuild the index $indexName

insert()

Converts the query into an INSERT.

into(string $target)

Inserts the INTO clause to a query.

$this
limit($limit)

Adds a limit to the current query.

$this
skip($records)

Adds a skip clause to the current query.

Link
link(string $class, string $property, string $alias, boolean $inverse = false)

Sets the internal command to a LINK, which is capable to create a reference from the $property of $class, with a given $alias.

lookup($indexName)

No description

on(string $on)

Sets the ON clause of a query.

orderBy(array $order, boolean $append = true, boolean $first = false)

Orders the query.

orWhere(string $condition, mixed $value = null)

Adds an OR clause to the query.

Remove
remove(array $updates, string $class, boolean $append = true)

Removes a link from a link-set|list.

resetWhere()

Resets the WHERE conditions.

Revoke
revoke(string $permission)

Converts the query into an REVOKE with the given $permission.

select(array $projections, boolean $append = true)

Adds an array of fields into the select part of the query.

type(string $type)

Sets the type clause of a query.

to(string $to)

Adds a subject to the query.

truncate(string $entity, boolean $andCluster = false)

Truncates an entity.

Insert
values(array $values, boolean $append = true)

Sets the values to be inserted into the current query.

unindex(string $property, string $class = null)

Removes a index

put(array $values, $class, $append = true)

Changes the internal command to an PUT, setting the class to update and the values to be written.

boolean
canHydrate()

Checks whether the current query returns records that can be hydrated

update($class)

Changes the internal command to an UPDATE, setting the class to update.

where(string $condition, mixed $value = null)

Adds the WHERE clause.

mixed
getCommandClass(string $id)

Returns on of the commands that belong to the query.

manageClass(string $action, string $class)

Sets the right class command based on the $action.

manageProperty($action, $class, $property, $type = null, $linked = null)

Sets the right property command based on the $action.

mixed
executeClassOrPropertyCommand(string $action, string $class, string $property = null, string $type = null, string $linked = null)

Executes a class or property command checking if the $property parameter is specified.

true
setCommands(array $commands)

Sets the internal command classes to use

__toString()

Returns the raw SQL statement

Details

__construct(array $target = array(), array $commands = array())

Builds a query with the given $command on the given $target.

Parameters

array $target
array $commands

Add add(array $updates, string $class, boolean $append = true)

Adds a relation in a link-list|set.

Parameters

array $updates
string $class
boolean $append

Return Value

Add

Alter alter(string $class, string $attribute, string $value)

Alters an attribute of a class.

Parameters

string $class
string $attribute
string $value

Return Value

Alter

Alter alterProperty(string $class, string $property, string $attribute, string $value)

Alters the $property of $class setting $sttribute to $value.

Parameters

string $class
string $property
string $attribute
string $value

Return Value

Alter

andWhere(string $condition, mixed $value = null)

Adds a where condition to the query.

Parameters

string $condition
mixed $value

between(string $key, string $left, string $right)

Converts a "normal" select into an index one.

You use do a select on an index you can use the between operator.

Parameters

string $key
string $left
string $right

mixed create($class, $property = null, string $type = null, string $linked = null)

Executes a CREATE of a $class, or of the $property in the given $class if $property is specified.

Parameters

$class
$property
string $type
string $linked

Return Value

mixed

Delete delete(string $from)

Executes a DELETE SQL query on the given class (= $from).

Parameters

string $from

Return Value

Delete

mixed drop(string $class, string $property = null)

Drops a $class, or the $property in the given $class if $property is specified.

Parameters

string $class
string $property

Return Value

mixed

Query fields(array $fields, boolean $append = true)

Sets the fields to query.

Parameters

array $fields
boolean $append

Return Value

Query

from(array $target, boolean $append = true)

Adds a from clause to the query.

Parameters

array $target
boolean $append

Command getCommand()

Returns the internal command.

Return Value

Command

String getRaw()

Returns the raw SQL query statement.

Return Value

String

array getTokens()

Returns the tokens associated to the current query.

Return Value

array

Grant grant(string $permission)

Converts the query into an GRANT with the given $permission.

Parameters

string $permission

Return Value

Grant

Find findReferences(string $rid, array $classes = array(), boolean $append = true)

Finds documents referencing the document with the given $rid.

You can specify to look for only certain $classes, that can be appended.

Parameters

string $rid
array $classes
boolean $append

Return Value

Find

mixed in(array $in, boolean $append = true)

Sets the classes in which the query performs is operation.

For example a FIND REFERENCES uses the IN in order to find documents referencing to a given document in N classes.

Parameters

array $in
boolean $append

Return Value

mixed

Query index(string $property, string $type, string $class = null)

Creates a index

Parameters

string $property
string $type
string $class

Return Value

Query

indexCount(string $indexName)

Count the elements of the index $indexName.

Parameters

string $indexName

indexPut(string $indexName, string $key, string $rid)

Puts a new entry in the index $indexName with the given $key and $rid.

Parameters

string $indexName
string $key
string $rid

indexRemove(string $indexName, string $key, string $rid = null)

Removes the index $indexName with the given $key/$rid.

Parameters

string $indexName
string $key
string $rid

rebuild(string $indexName)

Rebuild the index $indexName

Parameters

string $indexName

Query insert()

Converts the query into an INSERT.

Return Value

Query

Query into(string $target)

Inserts the INTO clause to a query.

Parameters

string $target

Return Value

Query

$this limit($limit)

Adds a limit to the current query.

Parameters

$limit

Return Value

$this

$this skip($records)

Adds a skip clause to the current query.

Parameters

$records

Return Value

$this

Sets the internal command to a LINK, which is capable to create a reference from the $property of $class, with a given $alias.

You can specify if the link is one-* or two-way with the $inverse parameter.

Parameters

string $class
string $property
string $alias
boolean $inverse

Return Value

Link

lookup($indexName)

Parameters

$indexName

Query on(string $on)

Sets the ON clause of a query.

Parameters

string $on

Return Value

Query

orderBy(array $order, boolean $append = true, boolean $first = false)

Orders the query.

Parameters

array $order
boolean $append
boolean $first

orWhere(string $condition, mixed $value = null)

Adds an OR clause to the query.

Parameters

string $condition
mixed $value

Remove remove(array $updates, string $class, boolean $append = true)

Removes a link from a link-set|list.

Parameters

array $updates
string $class
boolean $append

Return Value

Remove

resetWhere()

Resets the WHERE conditions.

Revoke revoke(string $permission)

Converts the query into an REVOKE with the given $permission.

Parameters

string $permission

Return Value

Revoke

select(array $projections, boolean $append = true)

Adds an array of fields into the select part of the query.

Parameters

array $projections
boolean $append

Query type(string $type)

Sets the type clause of a query.

Parameters

string $type

Return Value

Query

Query to(string $to)

Adds a subject to the query.

Parameters

string $to

Return Value

Query

Query truncate(string $entity, boolean $andCluster = false)

Truncates an entity.

Parameters

string $entity
boolean $andCluster

Return Value

Query

Insert values(array $values, boolean $append = true)

Sets the values to be inserted into the current query.

Parameters

array $values
boolean $append

Return Value

Insert

Query unindex(string $property, string $class = null)

Removes a index

Parameters

string $property
string $class

Return Value

Query

put(array $values, $class, $append = true)

Changes the internal command to an PUT, setting the class to update and the values to be written.

Parameters

array $values
$class
$append

boolean canHydrate()

Checks whether the current query returns records that can be hydrated

Return Value

boolean

update($class)

Changes the internal command to an UPDATE, setting the class to update.

Parameters

$class

where(string $condition, mixed $value = null)

Adds the WHERE clause.

Parameters

string $condition
mixed $value

protected mixed getCommandClass(string $id)

Returns on of the commands that belong to the query.

Parameters

string $id

Return Value

mixed

protected manageClass(string $action, string $class)

Sets the right class command based on the $action.

Parameters

string $action
string $class

protected manageProperty($action, $class, $property, $type = null, $linked = null)

Sets the right property command based on the $action.

Parameters

$action
$class
$property
$type
$linked

protected mixed executeClassOrPropertyCommand(string $action, string $class, string $property = null, string $type = null, string $linked = null)

Executes a class or property command checking if the $property parameter is specified.

If none, class command is executed.

Parameters

string $action
string $class
string $property
string $type
string $linked

Return Value

mixed

protected true setCommands(array $commands)

Sets the internal command classes to use

Parameters

array $commands

Return Value

true

__toString()

Returns the raw SQL statement