SilverShop\ORM\Filters\MatchObjectFilter
Helper class to create a filter for matching a dataobject, using field values or relationship ids and only those ids.
Combining fields defines a way to uniquely identify an object.
Useful for finding if a dataobject with given field values exists.
Protects against SQL injection, and searching on unauthroised fields.
Ignores fields that don't exist on the object.
Adds IS NULL, or = 0 for values that are not passed.
Similar to SearchContext
Conjunctive query
Example input:
$data = array(
'FieldName' => 'data'
'AnotherField' => 32,
'NotIncludedField' => 'blah'
);
$required = array(
'FieldName',
'AnotherField',
'ARequiredField'
);
Example output:
"FieldName" = 'data' AND "AnotherField" = 32 AND "ARequiredField" IS NULL
Synopsis
class MatchObjectFilter
{
- // members
- protected $className;
- protected $data;
- protected $required;
- // methods
- public void __construct()
- public array getFilter()
Members
protected
- $className
- $data
- $required
Methods
public
- __construct()
- getFilter() — Create SQL where filter