Mjoin
        
        extends Join
    
    
            
            in package
            
        
    
    
    
        
            The `Mjoin` class extends the `Join` class with the join data type set to 'array', whereas the `Join` default is `object` which has been rendered obsolete by the `Editor->leftJoin()` method. The API API is otherwise identical.
This class is recommended over the Join class.
Table of Contents
- __construct() : mixed
 - Join instance constructor.
 - aliasParentTable() : string|self
 - Get / set parent table alias.
 - field() : array<string|int, Field>|self
 - Get / set field instances.
 - fields() : array<string|int, Field>|self
 - Get / set field instances.
 - get() : bool|self
 - Get / set get attribute.
 - inst() : Editor|Field|Join|Upload
 - Static method to instantiate a new instance of a class (shorthand of 'instantiate').
 - instantiate() : Editor|Field|Join|Upload
 - Static method to instantiate a new instance of a class.
 - join() : mixed
 - Get / set join properties.
 - leftJoin() : self
 - Set up a left join operation for the Mjoined data.
 - link() : Join
 - Create a join link between two tables. The order of the fields does not matter, but each field must contain the table name as well as the field name.
 - name() : string|self
 - Get / set name.
 - order() : Join
 - Specify the property that the data will be sorted by.
 - set() : bool|self
 - Get / set set attribute.
 - table() : string|self
 - Get / set join table name.
 - type() : string|self
 - Get / set the join type.
 - validator() : self
 - Set a validator for the array of data (not on a field basis).
 - where() : array<string|int, string>|self
 - Where condition to add to the query used to get data from the database.
 - whereSet() : bool
 - Get / set if the WHERE conditions should be included in the create and edit actions.
 - _getSet() : self|mixed
 - Common getter / setter function for DataTables classes.
 - _propExists() : bool
 - Determine if a property is available in a data set (allowing `null` to be a valid value).
 - _readProp() : mixed
 - Read a value from a data structure, using Javascript dotted object notation. This is the inverse of the `_writeProp` method and provides the same support, matching DataTables' ability to read nested JSON data objects.
 - _writeProp() : mixed
 - Write the field's value to an array structure, using Javascript dotted object notation to indicate JSON data structure. For example `name.first` gives the data structure: `name: { first: ... }`. This matches DataTables own ability to do this on the client-side, although this doesn't implement implement quite such a complex structure (no array / function support).
 
Methods
__construct()
Join instance constructor.
    public
                    __construct([mixed $table = null ]) : mixed
    
        Parameters
- $table : mixed = null
 - 
                    
Table name to get the joined data from.
 
Return values
mixed —aliasParentTable()
Get / set parent table alias.
    public
                    aliasParentTable([string $_ = null ]) : string|self
        When working with a self referencing table (i.e. a column in the table contains a primary key value from its own table) it can be useful to set an alias on the parent table's name, allowing a self referencing Join. For example:
SELECT p2.publisher
FROM   publisher as p2
JOIN   publisher on (publisher.idPublisher = p2.idPublisher)
Where, in this case, publisher is the table that is used by the Editor instance,
and you want to use Join to link back to the table (resolving a name for example).
This method allows that alias to be set. Fields can then use standard SQL notation
to select a field, for example p2.publisher or publisher.publisher.
Parameters
- $_ : string = null
 - 
                    
Table alias to use
 
Return values
string|self —Table alias set (which is null by default), or self if used as a setter.
field()
Get / set field instances.
    public
                    field([mixed $_ = null ]) : array<string|int, Field>|self
        The list of fields designates which columns in the table that will be read from the joined table.
Parameters
- $_ : mixed = null
 
Tags
Return values
array<string|int, Field>|self —Array of fields, or self if used as a setter.
fields()
Get / set field instances.
    public
                    fields([mixed $_ = null ]) : array<string|int, Field>|self
        An alias of field, for convenience.
Parameters
- $_ : mixed = null
 
Tags
Return values
array<string|int, Field>|self —Array of fields, or self if used as a setter.
get()
Get / set get attribute.
    public
                    get([bool $_ = null ]) : bool|self
        When set to false no read operations will occur on the join tables.
Parameters
- $_ : bool = null
 - 
                    
Value
 
Return values
bool|self —Name
inst()
Static method to instantiate a new instance of a class (shorthand of 'instantiate').
    public
            static        inst() : Editor|Field|Join|Upload
        This method performs exactly the same actions as the 'instantiate' static method, but is simply shorter and easier to type!
Tags
Return values
Editor|Field|Join|Upload —class
instantiate()
Static method to instantiate a new instance of a class.
    public
            static        instantiate() : Editor|Field|Join|Upload
        A factory method that will create a new instance of the class that has extended 'Ext'. This allows classes to be instantiated and then chained - which otherwise isn't available until PHP 5.4. If using PHP 5.4 or later, simply create a 'new' instance of the target class and chain methods as normal.
Tags
Return values
Editor|Field|Join|Upload —Instantiated class
join()
Get / set join properties.
    public
                    join([string|array<string|int, string> $parent = null ][, string|array<string|int, string> $child = null ][, string $table = null ]) : mixed
        Define how the SQL will be performed, on what columns. There are basically two types of join that are supported by Editor here, a direct foreign key reference in the join table to the parent table's primary key, or a link table that contains just primary keys for the parent and child tables (this approach is usually used with a Join->type() of 'array' since you can often have multiple links between the two tables, while a direct foreign key reference will typically use a type of 'object' (i.e. a single entry).
Parameters
- $parent : string|array<string|int, string> = null
 - 
                    
Parent table's primary key names. If used with a link table (i.e. third parameter to this method is given, then an array should be used, with the first element being the pkey's name in the parent table, and the second element being the key's name in the link table.
 - $child : string|array<string|int, string> = null
 - 
                    
Child table's primary key names. If used with a link table (i.e. third parameter to this method is given, then an array should be used, with the first element being the pkey's name in the child table, and the second element being the key's name in the link table.
 - $table : string = null
 - 
                    
Join table name, if using a link table
 
Tags
Return values
mixed —leftJoin()
Set up a left join operation for the Mjoined data.
    public
                    leftJoin(string $table, string $field1, string $operator, string $field2) : self
    
        Parameters
- $table : string
 - 
                    
to get the information from
 - $field1 : string
 - 
                    
the first field to get the information from
 - $operator : string
 - 
                    
the operation to perform on the two fields
 - $field2 : string
 - 
                    
the second field to get the information from
 
Return values
self —link()
Create a join link between two tables. The order of the fields does not matter, but each field must contain the table name as well as the field name.
    public
                    link(string $field1, string $field2) : Join
        This method can be called a maximum of two times for an Mjoin instance:
- First time, creates a link between the Editor host table and a join table
 - Second time creates the links required for a link table.
 
Please refer to the Editor Mjoin documentation for further details: https://editor.datatables.net/manual/php
Parameters
- $field1 : string
 - 
                    
Table and field name
 - $field2 : string
 - 
                    
Table and field name
 
Return values
Join —Self for chaining
name()
Get / set name.
    public
                    name([string $_ = null ]) : string|self
        The name of the Join is the JSON property key that is used when
'getting' the data, and the HTTP property key (in a JSON style) when
'setting' data. Typically the name of the db table will be used here,
but this method allows that to be overridden.
Parameters
- $_ : string = null
 - 
                    
Field name
 
Return values
string|self —Name
order()
Specify the property that the data will be sorted by.
    public
                    order([string $_ = null ]) : Join
    
        Parameters
- $_ : string = null
 - 
                    
SQL column name to order the data by
 
Return values
Join —Self for chaining
set()
Get / set set attribute.
    public
                    set([bool $_ = null ]) : bool|self
        When set to false no write operations will occur on the join tables. This can be useful when you want to display information which is joined, but want to only perform write operations on the parent table.
Parameters
- $_ : bool = null
 - 
                    
Value
 
Return values
bool|self —Name
table()
Get / set join table name.
    public
                    table([string $_ = null ]) : string|self
        Please note that this will also set the Join->name() used by the Join as well. This is for convenience as the JSON output / HTTP input will typically use the same name as the database name. If you want to set a custom name, the Join->name() method must be called after this one.
Parameters
- $_ : string = null
 - 
                    
Name of the table to read the join data from
 
Return values
string|self —Name of the join table, or self if used as a setter.
type()
Get / set the join type.
    public
                    type([string $_ = null ]) : string|self
        The join type allows the data that is returned from the join to be given as an array (i.e. working with multiple possibly results for each record from the parent table), or as an object (i.e. working which one and only one result for each record form the parent table).
Parameters
- $_ : string = null
 - 
                    
Join type ('object') or an array of results ('array') for the join.
 
Return values
string|self —Join type, or self if used as a setter.
validator()
Set a validator for the array of data (not on a field basis).
    public
                    validator(string $fieldName, callable $fn) : self
    
        Parameters
- $fieldName : string
 - 
                    
Name of the field that any error should be shown against on the client-side
 - $fn : callable
 - 
                    
Callback function for validation
 
Return values
self —Chainable
where()
Where condition to add to the query used to get data from the database.
    public
                    where([string|callable $key = null ][, string|array<string|int, string> $value = null ][, string $op = '=' ]) : array<string|int, string>|self
        Note that this is applied to the child table.
Can be used in two different ways:
- Simple case: 
where( field, value, operator ) - Complex: 
where( fn ) 
Parameters
- $key : string|callable = null
 - 
                    
Single field name or a closure function
 - $value : string|array<string|int, string> = null
 - 
                    
Single field value, or an array of values.
 - $op : string = '='
 - 
                    
Condition operator: <, >, = etc
 
Return values
array<string|int, string>|self —Where condition array, or self if used as a setter.
whereSet()
Get / set if the WHERE conditions should be included in the create and edit actions.
    public
                    whereSet([bool $_ = null ]) : bool
        This means that the fields which have been used as part of the 'get'
WHERE condition (using the where() method) will be set as the values
given.
This is default false (i.e. they are not included).
Parameters
- $_ : bool = null
 - 
                    
Include (
true), or not (false) 
Return values
bool —Current value
_getSet()
Common getter / setter function for DataTables classes.
    protected
                    _getSet(mixed &$prop, mixed $val[, bool $array = false ]) : self|mixed
        This getter / setter method makes building getter / setting methods easier, by abstracting everything to a single function call.
Parameters
- $prop : mixed
 - 
                    
The property to set
 - $val : mixed
 - 
                    
The value to set - if given as null, then we assume that the function is being used as a getter.
 - $array : bool = false
 - 
                    
Treat the target property as an array or not (default false). If used as an array, then values passed in are added to the $prop array.
 
Return values
self|mixed —Class instance if setting (allowing chaining), or the value requested if getting.
_propExists()
Determine if a property is available in a data set (allowing `null` to be a valid value).
    protected
                    _propExists(string $name, array<string|int, mixed> $data) : bool
    
        Parameters
- $name : string
 - 
                    
Javascript dotted object name to write to
 - $data : array<string|int, mixed>
 - 
                    
Data source array to read from
 
Tags
Return values
bool —true if present, false otherwise
_readProp()
Read a value from a data structure, using Javascript dotted object notation. This is the inverse of the `_writeProp` method and provides the same support, matching DataTables' ability to read nested JSON data objects.
    protected
                    _readProp(string $name, array<string|int, mixed> $data) : mixed
    
        Parameters
- $name : string
 - 
                    
Javascript dotted object name to write to
 - $data : array<string|int, mixed>
 - 
                    
Data source array to read from
 
Tags
Return values
mixed —The read value, or null if no value found.
_writeProp()
Write the field's value to an array structure, using Javascript dotted object notation to indicate JSON data structure. For example `name.first` gives the data structure: `name: { first: ... }`. This matches DataTables own ability to do this on the client-side, although this doesn't implement implement quite such a complex structure (no array / function support).
    protected
                    _writeProp(array<string|int, mixed> &$out, string $name, mixed $value) : mixed
    
        Parameters
- $out : array<string|int, mixed>
 - 
                    
Array to write the data to
 - $name : string
 - 
                    
Javascript dotted object name to write to
 - $value : mixed
 - 
                    
Value to write