PHP Class LdapTools\Query\LdapQuery

Author: Chad Sikorra ([email protected])
Inheritance: use trait LdapTools\Hydrator\HydrateQueryTrait
Datei anzeigen Open project: ldaptools/ldaptools Class Usage Examples

Protected Properties

Property Type Description
$caseSensitive boolean
$hydratorFactory LdapTools\Factory\HydratorFactory
$ldap LdapTools\Connection\LdapConnectionInterface
$operation LdapTools\Operation\QueryOperation | null
$orderBy The attributes to order by, if any. They will be in ['attribute' => 'ASC'] form.
$schemas LdapTools\Schema\LdapObjectSchema[]

Public Methods

Method Description
__construct ( LdapTools\Connection\LdapConnectionInterface $ldap )
execute ( string $hydratorType = HydratorFactory::TO_OBJECT ) : mixed Execute a query based on the set parameters. Optionally choose a mode to hydrate the results in.
getArrayResult ( ) : array This is an alias for the execute() method with an implied array hydration type. This executes the query against LDAP and returns the results as an array instead of objects.
getIsCaseSensitiveSort ( ) : boolean Get whether or not the results should be sorted in a case-sensitive way.
getOneOrNullResult ( string $hydratorType = HydratorFactory::TO_OBJECT ) : array | LdapObject | null This behaves very similar to getSingleResult(), only if no results are found it will return null instead of throwing an exception.
getOrderBy ( ) : array Get the attributes to order the results by.
getQueryOperation ( ) : QueryOperation | null Get the query operation that will run against LDAP.
getResult ( string $hydratorType = HydratorFactory::TO_OBJECT ) : mixed This is an alias for the execute() method. This executes the query against LDAP and returns the result.
getSingleResult ( string $hydratorType = HydratorFactory::TO_OBJECT ) : array | LdapObject Retrieve a single unique result from LDAP. If the result is empty or contains more than one entry, an exception is thrown.
getSingleScalarOrNullResult ( ) : mixed This behaves very similar to getSingleScalarResult(), only if the attribute is not found it will return null instead of throwing an exception.
getSingleScalarResult ( ) : mixed Retrieve a single selected attribute value from LDAP.
setIsCaseSensitiveSort ( boolean $caseSensitive ) Set whether or not the results should be sorted in a case-sensitive way.
setOrderBy ( array $orderBy ) Set the attributes to order the results by.
setQueryOperation ( QueryOperation $operation ) Set the query operation to run against LDAP.

Protected Methods

Method Description
getFormattedOrderBy ( $selected, $aliases ) : array This formats the orderBy array to ignore case differences between the orderBy name and the actually selected name, such as for sorting arrays.
getResultsForAliases ( string $hydratorType ) : array | LdapObjectCollection | mixed Goes through each alias for the operation to get results only for that specific type, then combine and return them all.
getResultsFromLdap ( QueryOperation $operation, string $hydratorType, null | LdapObjectSchema $schema = null, null | string $alias = null ) : mixed
getSelectedForAllAliases ( array $aliases ) : array Get all the attributes that were selected for the query taking into account all of the aliases used.
sortResults ( mixed $results ) : mixed

Method Details

__construct() public method

public __construct ( LdapTools\Connection\LdapConnectionInterface $ldap )
$ldap LdapTools\Connection\LdapConnectionInterface

execute() public method

Execute a query based on the set parameters. Optionally choose a mode to hydrate the results in.
public execute ( string $hydratorType = HydratorFactory::TO_OBJECT ) : mixed
$hydratorType string A hyrdrator type constant from the factory.
return mixed

getArrayResult() public method

This is an alias for the execute() method with an implied array hydration type. This executes the query against LDAP and returns the results as an array instead of objects.
public getArrayResult ( ) : array
return array

getFormattedOrderBy() protected method

This formats the orderBy array to ignore case differences between the orderBy name and the actually selected name, such as for sorting arrays.
protected getFormattedOrderBy ( $selected, $aliases ) : array
$selected
$aliases
return array

getIsCaseSensitiveSort() public method

Get whether or not the results should be sorted in a case-sensitive way.
public getIsCaseSensitiveSort ( ) : boolean
return boolean

getOneOrNullResult() public method

This behaves very similar to getSingleResult(), only if no results are found it will return null instead of throwing an exception.
public getOneOrNullResult ( string $hydratorType = HydratorFactory::TO_OBJECT ) : array | LdapObject | null
$hydratorType string
return array | LdapTools\Object\LdapObject | null

getOrderBy() public method

Get the attributes to order the results by.
public getOrderBy ( ) : array
return array

getQueryOperation() public method

Get the query operation that will run against LDAP.
public getQueryOperation ( ) : QueryOperation | null
return LdapTools\Operation\QueryOperation | null

getResult() public method

This is an alias for the execute() method. This executes the query against LDAP and returns the result.
public getResult ( string $hydratorType = HydratorFactory::TO_OBJECT ) : mixed
$hydratorType string A hyrdrator type constant from the factory.
return mixed

getResultsForAliases() protected method

Goes through each alias for the operation to get results only for that specific type, then combine and return them all.
protected getResultsForAliases ( string $hydratorType ) : array | LdapObjectCollection | mixed
$hydratorType string
return array | LdapTools\Object\LdapObjectCollection | mixed

getResultsFromLdap() protected method

protected getResultsFromLdap ( QueryOperation $operation, string $hydratorType, null | LdapObjectSchema $schema = null, null | string $alias = null ) : mixed
$operation LdapTools\Operation\QueryOperation
$hydratorType string
$schema null | LdapTools\Schema\LdapObjectSchema
$alias null | string
return mixed

getSelectedForAllAliases() protected method

Get all the attributes that were selected for the query taking into account all of the aliases used.
protected getSelectedForAllAliases ( array $aliases ) : array
$aliases array
return array

getSingleResult() public method

Retrieve a single unique result from LDAP. If the result is empty or contains more than one entry, an exception is thrown.
public getSingleResult ( string $hydratorType = HydratorFactory::TO_OBJECT ) : array | LdapObject
$hydratorType string A hyrdrator type constant from the factory.
return array | LdapTools\Object\LdapObject

getSingleScalarOrNullResult() public method

This behaves very similar to getSingleScalarResult(), only if the attribute is not found it will return null instead of throwing an exception.

getSingleScalarResult() public method

Retrieve a single selected attribute value from LDAP.
public getSingleScalarResult ( ) : mixed
return mixed

setIsCaseSensitiveSort() public method

Set whether or not the results should be sorted in a case-sensitive way.
public setIsCaseSensitiveSort ( boolean $caseSensitive )
$caseSensitive boolean

setOrderBy() public method

Set the attributes to order the results by.
public setOrderBy ( array $orderBy )
$orderBy array In the form of ['attribute' => 'ASC', ...]

setQueryOperation() public method

Set the query operation to run against LDAP.
public setQueryOperation ( QueryOperation $operation )
$operation LdapTools\Operation\QueryOperation

sortResults() protected method

protected sortResults ( mixed $results ) : mixed
$results mixed
return mixed $results

Property Details

$caseSensitive protected_oe property

protected bool $caseSensitive
return boolean

$hydratorFactory protected_oe property

protected HydratorFactory,LdapTools\Factory $hydratorFactory
return LdapTools\Factory\HydratorFactory

$ldap protected_oe property

protected LdapConnectionInterface,LdapTools\Connection $ldap
return LdapTools\Connection\LdapConnectionInterface

$operation protected_oe property

protected QueryOperation,LdapTools\Operation|null $operation
return LdapTools\Operation\QueryOperation | null

$orderBy protected_oe property

The attributes to order by, if any. They will be in ['attribute' => 'ASC'] form.
protected $orderBy

$schemas protected_oe property

protected LdapObjectSchema[],LdapTools\Schema $schemas
return LdapTools\Schema\LdapObjectSchema[]