Copied!

Many To Many relationships need a junction table containing the primary keys of the two tables needing the many to many relationshp.

In the Record class definition, you need to define a virtual field with the name of the Many To Many relationship. The key of the virtual field is the member name and the value is an array.

The values in the array should be \PHPFUI\ORM\ManyToMany::class, followed by the junction table class name, then related table class name. Two additional parameters can be specified, the order by column and sort order (defaults to ASC).

Example:

protected static array $virtualFields = [
  'suppliers' => [\PHPFUI\ORM\ManyToMany::class, \Tests\App\Table\ProductSupplier::class, \Tests\App\Table\Supplier::class, 'company', ],
];
CloneableInstantiable
Methods
public PHPFUI\ORM\VirtualField::__construct(PHPFUI\ORM\Record $currentRecord, string $fieldName)
public getValue(array $parameters) : PHPFUI\ORM\RecordCursor
 
  • param string[] $parameters values are the junction table class name, then related table class name. Two additional parameters can be specified, the order by column and sort order (defaults to ASC).
public setValue(?mixed $value, array $parameters) : void
 
  • param mixed $value to set
  • param string[] $parameters values are the junction table class name, then related table class name. Two additional parameters can be specified, the order by column and sort order (defaults to ASC).
Properties
protected PHPFUI\ORM\Record PHPFUI\ORM\VirtualField::$currentRecord
protected string PHPFUI\ORM\VirtualField::$fieldName
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration