tflori/orm

just another orm...

View the Project on GitHub tflori/orm

Build Status Test Coverage Maintainability Latest Stable Version Total Downloads

» API Reference » ORM\Testing\EntityFetcherMock\Result

ORM\Testing\EntityFetcherMock\Result

Table of Contents

Abstract

Extends: ORM\EntityFetcher

Fetch entities from database

If you need more specific queries you write them yourself. If you need just more specific where clause you can pass them to the *where() methods.

Supported:

Properties

Visibility Name Type Description
public static $defaultEntityManager ORM\EntityManager The default EntityManager to use to for quoting

Methods

ORM\Testing\EntityFetcherMock\Result::__construct

public function __construct(
    \ORM\EntityManager $entityManager, 
    \ORM\Entity|string $class, 
)
Constructor
Parameters
Parameter Type Description  
$entityManager ORM\EntityManager EntityManager where to store the fetched entities  
$class **ORM\Entity string** Class to fetch

ORM\Testing\EntityFetcherMock\Result::__construct

↑ top


ORM\Testing\EntityFetcherMock\Result::addEntities

public function addEntities(\ORM\Entity[] $entities): $this
Add entities to the result
Returns $this  
Parameters
Parameter Type Description
$entities ORM\Entity[]  

ORM\Testing\EntityFetcherMock\Result::addEntities

↑ top


ORM\Testing\EntityFetcherMock\Result::all

public function all(int $limit): \ORM\Entity[]
Fetch an array of entities

When no $limit is set it fetches all entities in result set.

Returns ORM\Entity[]  
Parameters
Parameter Type Description
$limit int Maximum number of entities to fetch

ORM\Testing\EntityFetcherMock\Result::all

↑ top


ORM\Testing\EntityFetcherMock\Result::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND
Returns $this  

ORM\Testing\EntityFetcherMock\Result::andParenthesis

↑ top


ORM\Testing\EntityFetcherMock\Result::andWhere

public function andWhere(
    string $column, 
    string|array $operator = null, 
    string $value = null, 
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);
Returns $this  
Parameters
Parameter Type Description  
$column string Column or expression with placeholders  
$operator **string array** Operator, value or array of values
$value string Value (required when used with operator)  

ORM\Testing\EntityFetcherMock\Result::andWhere

↑ top


ORM\Testing\EntityFetcherMock\Result::close

public function close(
    , 
): \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
Close parenthesis
Returns ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface  

ORM\Testing\EntityFetcherMock\Result::close

↑ top


ORM\Testing\EntityFetcherMock\Result::column

public function column(
    mixed $column, 
    mixed $args = [], 
    mixed $alias = '', 
): $this
Add $column
Returns $this  
Parameters
Parameter Type Description
$column mixed Column or expression to fetch
$args mixed Arguments for expression
$alias mixed Alias for the column

ORM\Testing\EntityFetcherMock\Result::column

↑ top


ORM\Testing\EntityFetcherMock\Result::columns

public function columns(array $columns = null): $this
Set $columns
Returns $this  
Parameters
Parameter Type Description
$columns array  

ORM\Testing\EntityFetcherMock\Result::columns

↑ top


ORM\Testing\EntityFetcherMock\Result::compare

public function compare(\ORM\EntityFetcher $fetcher): int
Check if $fetcher matches the current query

Returns the score for the given EntityFetcher. The more conditions match the higher the score:

Returns int  
Parameters
Parameter Type Description
$fetcher ORM\EntityFetcher  

ORM\Testing\EntityFetcherMock\Result::compare

↑ top


ORM\Testing\EntityFetcherMock\Result::count

public function count(): int
Get the count of the resulting items
Returns int  

ORM\Testing\EntityFetcherMock\Result::count

↑ top


ORM\Testing\EntityFetcherMock\Result::createRelatedJoin

public function createRelatedJoin(mixed $join, mixed $relation): $this
Create the join with $join type
Returns $this  
Parameters
Parameter Type Description
$join mixed  
$relation mixed  

ORM\Testing\EntityFetcherMock\Result::createRelatedJoin

↑ top


ORM\Testing\EntityFetcherMock\Result::delete

public function delete(): int
Execute a delete statement on the current table with current where conditions
Returns int The number of deleted rows

ORM\Testing\EntityFetcherMock\Result::delete

↑ top


ORM\Testing\EntityFetcherMock\Result::filter

public function filter(
    string|\ORM\EntityFetcher\FilterInterface|callable $filter, 
): $this
Apply an additional $filter before executing
Returns $this  
Parameters
Parameter Type Description    
$filter **string ORM\EntityFetcher\FilterInterface callable**  

ORM\Testing\EntityFetcherMock\Result::filter

↑ top


ORM\Testing\EntityFetcherMock\Result::fullJoin

public function fullJoin(
    mixed $class, 
    mixed $expression = '', 
    mixed $alias = '', 
    mixed $args = [], 
): mixed
Returns mixed  
Parameters
Parameter Type Description
$class mixed  
$expression mixed  
$alias mixed  
$args mixed  

ORM\Testing\EntityFetcherMock\Result::fullJoin

↑ top


ORM\Testing\EntityFetcherMock\Result::getEntities

public function getEntities(): \ORM\Entity[]
Get the entities for this result
Returns ORM\Entity[]  

ORM\Testing\EntityFetcherMock\Result::getEntities

↑ top


ORM\Testing\EntityFetcherMock\Result::getEntityManager

public function getEntityManager(): \ORM\EntityManager
Returns ORM\EntityManager  

ORM\Testing\EntityFetcherMock\Result::getEntityManager

↑ top


ORM\Testing\EntityFetcherMock\Result::getExpression

public function getExpression(): string
Get the expression
Returns string  

ORM\Testing\EntityFetcherMock\Result::getExpression

↑ top


ORM\Testing\EntityFetcherMock\Result::getGlobalFilters

public static function getGlobalFilters(string $class): array
Get the filters registered for $class

A filter can be registered for the super class too.

Static   This method is static.
Returns array  
Parameters
Parameter Type Description
$class string  

ORM\Testing\EntityFetcherMock\Result::getGlobalFilters

↑ top


ORM\Testing\EntityFetcherMock\Result::getQuery

public function getQuery(): string
Get the query / select statement
Returns string  

ORM\Testing\EntityFetcherMock\Result::getQuery

↑ top


ORM\Testing\EntityFetcherMock\Result::groupBy

public function groupBy(mixed $column, mixed $args = []): $this
Group By $column
Returns $this  
Parameters
Parameter Type Description
$column mixed Column or expression for groups
$args mixed Arguments for expression

ORM\Testing\EntityFetcherMock\Result::groupBy

↑ top


ORM\Testing\EntityFetcherMock\Result::insert

public function insert(array $rows): int
Execute an insert statement on the current table
Returns int The number of inserted rows
Parameters
Parameter Type Description
$rows array  

ORM\Testing\EntityFetcherMock\Result::insert

↑ top


ORM\Testing\EntityFetcherMock\Result::join

public function join(
    mixed $class, 
    mixed $expression = '', 
    mixed $alias = '', 
    mixed $args = [], 
): mixed
Returns mixed  
Parameters
Parameter Type Description
$class mixed  
$expression mixed  
$alias mixed  
$args mixed  

ORM\Testing\EntityFetcherMock\Result::join

↑ top


ORM\Testing\EntityFetcherMock\Result::joinRelated

public function joinRelated(mixed $relation): $this
Join $relation
Returns $this  
Parameters
Parameter Type Description
$relation mixed  

ORM\Testing\EntityFetcherMock\Result::joinRelated

↑ top


ORM\Testing\EntityFetcherMock\Result::leftJoin

public function leftJoin(
    mixed $class, 
    mixed $expression = '', 
    mixed $alias = '', 
    mixed $args = [], 
): mixed
Returns mixed  
Parameters
Parameter Type Description
$class mixed  
$expression mixed  
$alias mixed  
$args mixed  

ORM\Testing\EntityFetcherMock\Result::leftJoin

↑ top


ORM\Testing\EntityFetcherMock\Result::leftJoinRelated

public function leftJoinRelated(mixed $relation): $this
Left outer join $relation
Returns $this  
Parameters
Parameter Type Description
$relation mixed  

ORM\Testing\EntityFetcherMock\Result::leftJoinRelated

↑ top


ORM\Testing\EntityFetcherMock\Result::limit

public function limit(mixed $limit): $this
Set $limit
Returns $this  
Parameters
Parameter Type Description
$limit mixed The limit to set

ORM\Testing\EntityFetcherMock\Result::limit

↑ top


ORM\Testing\EntityFetcherMock\Result::matches

public function matches(string $expression): $this
Add a regular expression that has to match
Returns $this  
Parameters
Parameter Type Description
$expression string  

ORM\Testing\EntityFetcherMock\Result::matches

↑ top


ORM\Testing\EntityFetcherMock\Result::modifier

public function modifier(mixed $modifier): $this
Add $modifier
Returns $this  
Parameters
Parameter Type Description
$modifier mixed  

ORM\Testing\EntityFetcherMock\Result::modifier

↑ top


ORM\Testing\EntityFetcherMock\Result::offset

public function offset(mixed $offset): $this
Set $offset
Returns $this  
Parameters
Parameter Type Description
$offset mixed The offset to set

ORM\Testing\EntityFetcherMock\Result::offset

↑ top


ORM\Testing\EntityFetcherMock\Result::one

public function one(): \ORM\Entity
Fetch one entity

If there is no more entity in the result set it returns null.

Returns ORM\Entity  

ORM\Testing\EntityFetcherMock\Result::one

↑ top


ORM\Testing\EntityFetcherMock\Result::orderBy

public function orderBy(
    mixed $column, 
    mixed $direction = self::DIRECTION_ASCENDING, 
    mixed $args = [], 
): $this
Order By $column in $direction
Returns $this  
Parameters
Parameter Type Description
$column mixed Column or expression for order
$direction mixed Direction (default: ASC)
$args mixed Arguments for expression

ORM\Testing\EntityFetcherMock\Result::orderBy

↑ top


ORM\Testing\EntityFetcherMock\Result::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR
Returns $this  

ORM\Testing\EntityFetcherMock\Result::orParenthesis

↑ top


ORM\Testing\EntityFetcherMock\Result::orWhere

public function orWhere(
    string $column, 
    string|array $operator = null, 
    string $value = null, 
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);
Returns $this  
Parameters
Parameter Type Description  
$column string Column or expression with placeholders  
$operator **string array** Operator, value or array of values
$value string Value (required when used with operator)  

ORM\Testing\EntityFetcherMock\Result::orWhere

↑ top


ORM\Testing\EntityFetcherMock\Result::orWhereIn

public function orWhereIn(string|array $column, array $values): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Returns $this  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\Testing\EntityFetcherMock\Result::orWhereIn

↑ top


ORM\Testing\EntityFetcherMock\Result::orWhereNotIn

public function orWhereNotIn(string|array $column, array $values): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Returns $this  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\Testing\EntityFetcherMock\Result::orWhereNotIn

↑ top


ORM\Testing\EntityFetcherMock\Result::parenthesis

public function parenthesis(): $this
Alias for andParenthesis
Returns $this  

ORM\Testing\EntityFetcherMock\Result::parenthesis

↑ top


ORM\Testing\EntityFetcherMock\Result::registerGlobalFilter

public static function registerGlobalFilter(
    mixed $class, 
    string|\ORM\EntityFetcher\FilterInterface|callable $filter, 
): mixed
Register $filter globally for $class

A registered filter will be applied in all entity fetchers for the class if not excluded by $fetcher->withoutFilter(Filter::class).

Static   This method is static.
Returns mixed  
Parameters
Parameter Type Description    
$class mixed      
$filter **string ORM\EntityFetcher\FilterInterface callable**  

ORM\Testing\EntityFetcherMock\Result::registerGlobalFilter

↑ top


ORM\Testing\EntityFetcherMock\Result::reset

public function reset(): $this
Reset the position of the cursor to the first row
Returns $this  

ORM\Testing\EntityFetcherMock\Result::reset

↑ top


ORM\Testing\EntityFetcherMock\Result::rightJoin

public function rightJoin(
    mixed $class, 
    mixed $expression = '', 
    mixed $alias = '', 
    mixed $args = [], 
): mixed
Returns mixed  
Parameters
Parameter Type Description
$class mixed  
$expression mixed  
$alias mixed  
$args mixed  

ORM\Testing\EntityFetcherMock\Result::rightJoin

↑ top


ORM\Testing\EntityFetcherMock\Result::setFetchMode

public function setFetchMode(
    int $mode, 
    int|string|object $classNameObject = null, 
    array $constructorArgs = null, 
): $this
Proxy to PDOStatement::setFetchMode()

Please note that this will execute the query - further modifications will not have any effect.

Returns $this  
Parameters
Parameter Type Description    
$mode int one of the PDO::FETCH_ constants    
$classNameObject **int string object** class (FETCH_CLASS), column number (FETCH_COLUMN), object (FETCH_INTO)
$constructorArgs array arguments to pass to the constructor (FETCH_CLASS)    

See Also:

ORM\Testing\EntityFetcherMock\Result::setFetchMode

↑ top


ORM\Testing\EntityFetcherMock\Result::setQuery

public function setQuery(
    string|\ORM\QueryBuilder\QueryBuilderInterface $query, 
    array $args = null, 
): $this
Set a raw query or use different QueryBuilder

For easier use and against sql injection it allows question mark placeholders.

Please be aware that this query is not touched at all and neither filters nor where conditions are applied.

Returns $this  
Parameters
Parameter Type Description  
$query **string ORM\QueryBuilder\QueryBuilderInterface** Raw query string or a QueryBuilderInterface
$args array The arguments for placeholders  

ORM\Testing\EntityFetcherMock\Result::setQuery

↑ top


ORM\Testing\EntityFetcherMock\Result::update

public function update(array $updates): int
Execute an update statement for the current query

NOTE: not all drivers support UPDATE with JOIN (or FROM). Has to be implemented in the database abstraction layer.

$updates should be an array which columns to update with what value. Use expressions to bypass escaping.

Returns int The number of affected rows
Parameters
Parameter Type Description
$updates array An array of columns to update

ORM\Testing\EntityFetcherMock\Result::update

↑ top


ORM\Testing\EntityFetcherMock\Result::where

public function where(
    string $column, 
    mixed $operator = null, 
    mixed $value = null, 
): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);
Returns $this  
Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

ORM\Testing\EntityFetcherMock\Result::where

↑ top


ORM\Testing\EntityFetcherMock\Result::whereIn

public function whereIn(string|array $column, array $values): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Returns $this  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\Testing\EntityFetcherMock\Result::whereIn

↑ top


ORM\Testing\EntityFetcherMock\Result::whereNotIn

public function whereNotIn(string|array $column, array $values): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Returns $this  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\Testing\EntityFetcherMock\Result::whereNotIn

↑ top


ORM\Testing\EntityFetcherMock\Result::with

public function with(string $relations): $this
Load $relations after all objects are loaded

The relations are only loaded after you execute ->all()

Returns $this  
Parameters
Parameter Type Description
$relations string  

ORM\Testing\EntityFetcherMock\Result::with

↑ top


ORM\Testing\EntityFetcherMock\Result::withoutFilter

public function withoutFilter(string $filterClass): $this
Exclude $filterClass for this fetcher
Returns $this  
Parameters
Parameter Type Description
$filterClass string  

ORM\Testing\EntityFetcherMock\Result::withoutFilter

↑ top