PHP Class Adldap\Query\Builder

Mostrar archivo Open project: adldap2/adldap2 Class Usage Examples

Public Properties

Property Type Description
$paginated boolean Determines whether the current query is paginated.

Protected Properties

Property Type Description
$bindings array The query bindings.
$connection Adldap\Connections\ConnectionInterface The current connection instance.
$dn string | null The distinguished name to perform searches upon.
$grammar Grammar The current grammar instance.
$raw boolean Determines whether or not to return LDAP results in their raw array format.
$read boolean Determines whether or not to search LDAP on the base scope.
$recursive boolean Determines whether or not to search LDAP recursively.
$schema Adldap\Schemas\SchemaInterface The current schema instance.
$sortByDirection string The direction to sort the results by.
$sortByField string The field to sort search results by.
$sortByFlags integer The sort flags for sorting query results.

Public Methods

Method Description
__call ( string $method, array $parameters ) : mixed Handle dynamic method calls on the query builder object to be directed to the query processor.
__construct ( Adldap\Connections\ConnectionInterface $connection, Grammar $grammar, Adldap\Schemas\SchemaInterface $schema = null ) Constructor.
addBinding ( Adldap\Query\Bindings\AbstractBinding $value, string $type = 'where' ) : Builder Adds a binding to the current query.
clearBindings ( ) : Builder Clears all query bindings.
dynamicWhere ( string $method, string $parameters ) Handles dynamic "where" clauses to the query.
find ( string $anr, array | string $columns = [] ) : mixed Finds a record using ambiguous name resolution.
findBaseDn ( ) : string | boolean Finds the Base DN of your domain controller.
findBy ( string $attribute, string $value, array | string $columns = [] ) : mixed Finds a record by the specified attribute and value.
findByDn ( string | array $dn, array | string $columns = [] ) : boolean | Model Finds a record by its distinguished name.
findByDnOrFail ( string $dn, array | string $columns = [] ) : Model Finds a record by its distinguished name.
findByOrFail ( string $attribute, string $value, array | string $columns = [] ) : mixed Finds a record by the specified attribute and value.
findBySid ( string $sid, array | string $columns = [] ) : mixed Finds a record by its Object SID.
findMany ( array $anrs = [], array $columns = [] ) : mixed Finds multiple records using ambiguous name resolution.
findManyBy ( string $attribute, array $values = [], array $columns = [] ) : mixed Finds many records by the specified attribute.
findOrFail ( string $anr, array | string $columns = [] ) : mixed Finds a record using ambiguous name resolution. If a record is not found, an exception is thrown.
first ( array | string $columns = [] ) : Model | array | null Returns the first entry in a search result.
firstOrFail ( array | string $columns = [] ) : Model Returns the first entry in a search result.
get ( ) : Collection | array Returns the current query.
getBindings ( ) : array Returns all of the query builder bindings.
getConnection ( ) : Adldap\Connections\ConnectionInterface Returns the current Connection instance.
getDn ( ) : string Returns the builders DN to perform searches upon.
getFilters ( ) : array Returns the filters on the current builder.
getGrammar ( ) : Grammar Returns the current Grammar instance.
getOrWheres ( ) : array Returns the or wheres on the current builder.
getQuery ( ) : string Compiles and returns the current query string.
getSchema ( ) : Adldap\Schemas\SchemaInterface Returns the current schema.
getSelects ( ) : array Returns the current selected fields to retrieve.
getSortByDirection ( ) : string Returns the query builders sort by direction.
getSortByField ( ) : string Returns the query builders sort by field.
getSortByFlags ( ) : integer Returns the query builders sort by flags.
getUnescapedQuery ( ) : string Returns the unescaped query.
getWheres ( ) : array Returns the wheres on the current builder.
hasSelects ( ) : boolean Returns true / false depending if the current object contains selects.
in ( string $dn ) : Builder Alias for setting the base DN of the query.
isPaginated ( ) : boolean Returns bool that determines whether the current query builder will return paginated results.
isRaw ( ) : boolean Returns bool that determines whether the current query builder will return raw results.
isSorted ( ) : boolean Returns bool that determines whether the current query builder will return sorted results.
newInstance ( ) : Builder Returns a new Query Builder instance.
orWhere ( string $field, string | null $operator = null, string | null $value = null ) : Builder Adds an or where clause to the current query.
orWhereApproximatelyEquals ( string $field, string $value ) : Builder Adds a or where approximately equals clause to the current query.
orWhereContains ( string $field, string $value ) : Builder Adds an or where contains clause to the current query.
orWhereEndsWith ( string $field, string $value ) : Builder Adds an or where ends with clause to the current query.
orWhereEquals ( string $field, string $value ) : Builder Adds an or where equals clause to the current query.
orWhereHas ( string $field ) : Builder Adds an or where has clause to the current query.
orWhereNotContains ( string $field, string $value ) : Builder Adds an or where *not* contains clause to the current query.
orWhereNotEndsWith ( string $field, string $value ) : Builder Adds an or where *not* ends with clause to the current query.
orWhereNotHas ( string $field ) : Builder Adds a where not has clause to the current query.
orWhereNotStartsWith ( string $field, string $value ) : Builder Adds an or where *not* starts with clause to the current query.
orWhereStartsWith ( string $field, string $value ) : Builder Adds an or where starts with clause to the current query.
paginate ( integer $perPage = 50, integer $currentPage, boolean $isCritical = true ) : Paginator | boolean Paginates the current LDAP query.
query ( string $query ) : Collection | array Performs the specified query on the current LDAP connection.
raw ( boolean $raw = true ) : Builder Sets the recursive property to tell the search whether or not to return the LDAP results in their raw format.
rawFilter ( array | string $filters = [] ) : Builder Adds a raw filter to the current query.
read ( boolean $read = true ) : Builder Sets the recursive property to tell the search whether or not to search on the base scope and return a single entry.
recursive ( boolean $recursive = true ) : Builder Sets the recursive property to tell the search whether or not to search recursively.
select ( array | string $fields = [] ) : Builder Adds the inserted fields to query on the current LDAP connection.
setConnection ( Adldap\Connections\ConnectionInterface $connection ) : Builder Sets the current connection.
setDn ( string | null $dn = null ) : Builder Sets the DN to perform searches upon.
setGrammar ( Grammar $grammar ) : Builder Sets the current filter grammar.
setSchema ( Adldap\Schemas\SchemaInterface $schema = null ) : Builder Sets the current schema.
sortBy ( string $field, string $direction = 'asc', integer | null $flags = null ) : Builder Sorts the LDAP search results by the specified field and direction.
where ( string | array $field, string $operator = null, string $value = null, string $type = 'and' ) : Builder Adds a where clause to the current query.
whereApproximatelyEquals ( string $field, string $value ) : Builder Adds a where approximately equals clause to the current query.
whereContains ( string $field, string $value ) : Builder Adds a where contains clause to the current query.
whereDisabled ( ) : Builder Adds a disabled filter to the current query.
whereEnabled ( ) : Builder Adds a enabled filter to the current query.
whereEndsWith ( string $field, string $value ) : Builder Adds a where ends with clause to the current query.
whereEquals ( string $field, string $value ) : Builder Adds a where equals clause to the current query.
whereHas ( string $field ) : Builder Adds a where has clause to the current query.
whereNotContains ( string $field, string $value ) : Builder Adds a where contains clause to the current query.
whereNotHas ( string $field ) : Builder Adds a where not has clause to the current query.
whereNotStartsWith ( string $field, string $value ) : Builder Adds a where *not* starts with clause to the current query.
whereStartsWith ( string $field, string $value ) : Builder Adds a where starts with clause to the current query.

Protected Methods

Method Description
addDynamic ( string $segment, string $connector, array $parameters, integer $index ) : void Add a single dynamic where clause statement to the query.
newProcessor ( ) : Processor Returns a new query Processor instance.
newWhereBinding ( string $field, string $operator, string | null $value = null, string $type = 'and' ) : Where | Adldap\Query\Bindings\OrWhere Constructs a new where binding depending on the specified type.

Method Details

__call() public method

Handle dynamic method calls on the query builder object to be directed to the query processor.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
return mixed

__construct() public method

Constructor.
public __construct ( Adldap\Connections\ConnectionInterface $connection, Grammar $grammar, Adldap\Schemas\SchemaInterface $schema = null )
$connection Adldap\Connections\ConnectionInterface
$grammar Grammar
$schema Adldap\Schemas\SchemaInterface

addBinding() public method

Adds a binding to the current query.
public addBinding ( Adldap\Query\Bindings\AbstractBinding $value, string $type = 'where' ) : Builder
$value Adldap\Query\Bindings\AbstractBinding
$type string
return Builder

addDynamic() protected method

Add a single dynamic where clause statement to the query.
protected addDynamic ( string $segment, string $connector, array $parameters, integer $index ) : void
$segment string
$connector string
$parameters array
$index integer
return void

clearBindings() public method

Clears all query bindings.
public clearBindings ( ) : Builder
return Builder

dynamicWhere() public method

Handles dynamic "where" clauses to the query.
public dynamicWhere ( string $method, string $parameters )
$method string
$parameters string

find() public method

Finds a record using ambiguous name resolution.
public find ( string $anr, array | string $columns = [] ) : mixed
$anr string
$columns array | string
return mixed

findBaseDn() public method

Finds the Base DN of your domain controller.
public findBaseDn ( ) : string | boolean
return string | boolean

findBy() public method

Finds a record by the specified attribute and value.
public findBy ( string $attribute, string $value, array | string $columns = [] ) : mixed
$attribute string
$value string
$columns array | string
return mixed

findByDn() public method

Finds a record by its distinguished name.
public findByDn ( string | array $dn, array | string $columns = [] ) : boolean | Model
$dn string | array
$columns array | string
return boolean | Adldap\Models\Model

findByDnOrFail() public method

Fails upon no records returned.
public findByDnOrFail ( string $dn, array | string $columns = [] ) : Model
$dn string
$columns array | string
return Adldap\Models\Model

findByOrFail() public method

If no record is found an exception is thrown.
public findByOrFail ( string $attribute, string $value, array | string $columns = [] ) : mixed
$attribute string
$value string
$columns array | string
return mixed

findBySid() public method

Finds a record by its Object SID.
public findBySid ( string $sid, array | string $columns = [] ) : mixed
$sid string
$columns array | string
return mixed

findMany() public method

Finds multiple records using ambiguous name resolution.
public findMany ( array $anrs = [], array $columns = [] ) : mixed
$anrs array
$columns array
return mixed

findManyBy() public method

Finds many records by the specified attribute.
public findManyBy ( string $attribute, array $values = [], array $columns = [] ) : mixed
$attribute string
$values array
$columns array
return mixed

findOrFail() public method

Finds a record using ambiguous name resolution. If a record is not found, an exception is thrown.
public findOrFail ( string $anr, array | string $columns = [] ) : mixed
$anr string
$columns array | string
return mixed

first() public method

Returns the first entry in a search result.
public first ( array | string $columns = [] ) : Model | array | null
$columns array | string
return Adldap\Models\Model | array | null

firstOrFail() public method

If no entry is found, an exception is thrown.
public firstOrFail ( array | string $columns = [] ) : Model
$columns array | string
return Adldap\Models\Model

get() public method

Returns the current query.
public get ( ) : Collection | array
return Illuminate\Support\Collection | array

getBindings() public method

Returns all of the query builder bindings.
public getBindings ( ) : array
return array

getConnection() public method

Returns the current Connection instance.
public getConnection ( ) : Adldap\Connections\ConnectionInterface
return Adldap\Connections\ConnectionInterface

getDn() public method

Returns the builders DN to perform searches upon.
public getDn ( ) : string
return string

getFilters() public method

Returns the filters on the current builder.
public getFilters ( ) : array
return array

getGrammar() public method

Returns the current Grammar instance.
public getGrammar ( ) : Grammar
return Grammar

getOrWheres() public method

Returns the or wheres on the current builder.
public getOrWheres ( ) : array
return array

getQuery() public method

Compiles and returns the current query string.
public getQuery ( ) : string
return string

getSchema() public method

Returns the current schema.
public getSchema ( ) : Adldap\Schemas\SchemaInterface
return Adldap\Schemas\SchemaInterface

getSelects() public method

Returns the current selected fields to retrieve.
public getSelects ( ) : array
return array

getSortByDirection() public method

Returns the query builders sort by direction.
public getSortByDirection ( ) : string
return string

getSortByField() public method

Returns the query builders sort by field.
public getSortByField ( ) : string
return string

getSortByFlags() public method

Returns the query builders sort by flags.
public getSortByFlags ( ) : integer
return integer

getUnescapedQuery() public method

Returns the unescaped query.
public getUnescapedQuery ( ) : string
return string

getWheres() public method

Returns the wheres on the current builder.
public getWheres ( ) : array
return array

hasSelects() public method

Returns true / false depending if the current object contains selects.
public hasSelects ( ) : boolean
return boolean

in() public method

Alias for setting the base DN of the query.
public in ( string $dn ) : Builder
$dn string
return Builder

isPaginated() public method

Returns bool that determines whether the current query builder will return paginated results.
public isPaginated ( ) : boolean
return boolean

isRaw() public method

Returns bool that determines whether the current query builder will return raw results.
public isRaw ( ) : boolean
return boolean

isSorted() public method

Returns bool that determines whether the current query builder will return sorted results.
public isSorted ( ) : boolean
return boolean

newInstance() public method

Returns a new Query Builder instance.
public newInstance ( ) : Builder
return Builder

newProcessor() protected method

Returns a new query Processor instance.
protected newProcessor ( ) : Processor
return Processor

newWhereBinding() protected method

Constructs a new where binding depending on the specified type.
protected newWhereBinding ( string $field, string $operator, string | null $value = null, string $type = 'and' ) : Where | Adldap\Query\Bindings\OrWhere
$field string
$operator string
$value string | null
$type string
return Adldap\Query\Bindings\Where | Adldap\Query\Bindings\OrWhere

orWhere() public method

Adds an or where clause to the current query.
public orWhere ( string $field, string | null $operator = null, string | null $value = null ) : Builder
$field string
$operator string | null
$value string | null
return Builder

orWhereApproximatelyEquals() public method

Adds a or where approximately equals clause to the current query.
public orWhereApproximatelyEquals ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereContains() public method

Adds an or where contains clause to the current query.
public orWhereContains ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereEndsWith() public method

Adds an or where ends with clause to the current query.
public orWhereEndsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereEquals() public method

Adds an or where equals clause to the current query.
public orWhereEquals ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereHas() public method

Adds an or where has clause to the current query.
public orWhereHas ( string $field ) : Builder
$field string
return Builder

orWhereNotContains() public method

Adds an or where *not* contains clause to the current query.
public orWhereNotContains ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereNotEndsWith() public method

Adds an or where *not* ends with clause to the current query.
public orWhereNotEndsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereNotHas() public method

Adds a where not has clause to the current query.
public orWhereNotHas ( string $field ) : Builder
$field string
return Builder

orWhereNotStartsWith() public method

Adds an or where *not* starts with clause to the current query.
public orWhereNotStartsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

orWhereStartsWith() public method

Adds an or where starts with clause to the current query.
public orWhereStartsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

paginate() public method

Paginates the current LDAP query.
public paginate ( integer $perPage = 50, integer $currentPage, boolean $isCritical = true ) : Paginator | boolean
$perPage integer
$currentPage integer
$isCritical boolean
return Adldap\Objects\Paginator | boolean

query() public method

Performs the specified query on the current LDAP connection.
public query ( string $query ) : Collection | array
$query string
return Illuminate\Support\Collection | array

raw() public method

Sets the recursive property to tell the search whether or not to return the LDAP results in their raw format.
public raw ( boolean $raw = true ) : Builder
$raw boolean
return Builder

rawFilter() public method

Adds a raw filter to the current query.
public rawFilter ( array | string $filters = [] ) : Builder
$filters array | string
return Builder

read() public method

Sets the recursive property to tell the search whether or not to search on the base scope and return a single entry.
public read ( boolean $read = true ) : Builder
$read boolean
return Builder

recursive() public method

Sets the recursive property to tell the search whether or not to search recursively.
public recursive ( boolean $recursive = true ) : Builder
$recursive boolean
return Builder

select() public method

Adds the inserted fields to query on the current LDAP connection.
public select ( array | string $fields = [] ) : Builder
$fields array | string
return Builder

setConnection() public method

Sets the current connection.
public setConnection ( Adldap\Connections\ConnectionInterface $connection ) : Builder
$connection Adldap\Connections\ConnectionInterface
return Builder

setDn() public method

Sets the DN to perform searches upon.
public setDn ( string | null $dn = null ) : Builder
$dn string | null
return Builder

setGrammar() public method

Sets the current filter grammar.
public setGrammar ( Grammar $grammar ) : Builder
$grammar Grammar
return Builder

setSchema() public method

Sets the current schema.
public setSchema ( Adldap\Schemas\SchemaInterface $schema = null ) : Builder
$schema Adldap\Schemas\SchemaInterface
return Builder

sortBy() public method

Sorts the LDAP search results by the specified field and direction.
public sortBy ( string $field, string $direction = 'asc', integer | null $flags = null ) : Builder
$field string
$direction string
$flags integer | null
return Builder

where() public method

Adds a where clause to the current query.
public where ( string | array $field, string $operator = null, string $value = null, string $type = 'and' ) : Builder
$field string | array
$operator string
$value string
$type string
return Builder

whereApproximatelyEquals() public method

Adds a where approximately equals clause to the current query.
public whereApproximatelyEquals ( string $field, string $value ) : Builder
$field string
$value string
return Builder

whereContains() public method

Adds a where contains clause to the current query.
public whereContains ( string $field, string $value ) : Builder
$field string
$value string
return Builder

whereDisabled() public method

Adds a disabled filter to the current query.
public whereDisabled ( ) : Builder
return Builder

whereEnabled() public method

Adds a enabled filter to the current query.
public whereEnabled ( ) : Builder
return Builder

whereEndsWith() public method

Adds a where ends with clause to the current query.
public whereEndsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

whereEquals() public method

Adds a where equals clause to the current query.
public whereEquals ( string $field, string $value ) : Builder
$field string
$value string
return Builder

whereHas() public method

Adds a where has clause to the current query.
public whereHas ( string $field ) : Builder
$field string
return Builder

whereNotContains() public method

Adds a where contains clause to the current query.
public whereNotContains ( string $field, string $value ) : Builder
$field string
$value string
return Builder

whereNotHas() public method

Adds a where not has clause to the current query.
public whereNotHas ( string $field ) : Builder
$field string
return Builder

whereNotStartsWith() public method

Adds a where *not* starts with clause to the current query.
public whereNotStartsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

whereStartsWith() public method

Adds a where starts with clause to the current query.
public whereStartsWith ( string $field, string $value ) : Builder
$field string
$value string
return Builder

Property Details

$bindings protected_oe property

The query bindings.
protected array $bindings
return array

$connection protected_oe property

The current connection instance.
protected ConnectionInterface,Adldap\Connections $connection
return Adldap\Connections\ConnectionInterface

$dn protected_oe property

The distinguished name to perform searches upon.
protected string|null $dn
return string | null

$grammar protected_oe property

The current grammar instance.
protected Grammar,Adldap\Query $grammar
return Grammar

$paginated public_oe property

Determines whether the current query is paginated.
public bool $paginated
return boolean

$raw protected_oe property

Determines whether or not to return LDAP results in their raw array format.
protected bool $raw
return boolean

$read protected_oe property

Determines whether or not to search LDAP on the base scope.
protected bool $read
return boolean

$recursive protected_oe property

Determines whether or not to search LDAP recursively.
protected bool $recursive
return boolean

$schema protected_oe property

The current schema instance.
protected SchemaInterface,Adldap\Schemas $schema
return Adldap\Schemas\SchemaInterface

$sortByDirection protected_oe property

The direction to sort the results by.
protected string $sortByDirection
return string

$sortByField protected_oe property

The field to sort search results by.
protected string $sortByField
return string

$sortByFlags protected_oe property

The sort flags for sorting query results.
protected int $sortByFlags
return integer