Menu

## SQLManyToOneColumn extends SQLColumn
in package

SQLManyToOneColumn.php : 18

Allows to define Many to One Columns.

Example: Book <> Author. Field "author_id" in table "books" is the Many to One Column.

##### Tags

internal

### Table of Contents

VALID_OPTIONS = ['required', 'enum', 'max', 'min', 'tooltip', 'description', 'suffix', 'step', 'email', 'link', 'textarea', 'readonly', 'hidden', 'list', 'card', 'create', 'update', 'url', 'imageUrl']
VALID_TYPES = ['text' => 'text', 'string' => 'text', 'integer' => 'integer', 'bigint' => 'integer', 'biginteger' => 'integer', 'smallint' => 'integer', 'int' => 'integer', 'decimal' => 'decimal', 'dec' => 'decimal', 'double' => 'decimal', 'float' => 'decimal', 'enum' => 'enum', 'datetime' => 'datetime', 'date' => 'date', 'time' => 'time', 'boolean' => 'boolean', 'bool' => 'boolean', 'tinyint' => 'boolean', 'blob' => 'blob', 'binary' => 'blob', 'bin' => 'blob', 'image' => 'image', 'picture' => 'image']
$ajax : bool
$columnName : string
$filterDefinitions : array<string|int, FilterDefinition>
$isCustomAjax : bool
$isManyToOne : bool
$label : string
$manualInput : bool
$name : string
$onLoadCallback : callable
$onSearchCallback : callable
$options : array<string|int, mixed>
$pageId : string
$secondaryColumnNames : array<string|int, string>
$toTableName : string
$type : string
$ajaxOptions : AjaxOptions
__construct() : mixed
  Creates a new Many to One Column
getAjaxOptions() : AjaxOptions
getCardUrl() : string
  Gets the url to the card page of the related record.
getColumnsForSelect() : array<string|int, string>
getManyToOneValues() : array<string|int, mixed>
  Gets array of values.
isHidden() : bool
  Checks if the column is hidden (in general or on a specific page type.)
mapDatatype() : string
  Maps various names for datatypes to a uniform name.
setAjaxOptions() : void
triggerOnLoadEvent() : mixed
triggerOnSearchEvent() : mixed
checkOptions() : mixed

### Constants

#### VALID_OPTIONS

SQLColumn.php : 83
`public mixed VALID_OPTIONS = ['required', 'enum', 'max', 'min', 'tooltip', 'description', 'suffix', 'step', 'email', 'link', 'textarea', 'readonly', 'hidden', 'list', 'card', 'create', 'update', 'url', 'imageUrl']`

#### VALID_TYPES

SQLColumn.php : 56
`public array<string|int, string> VALID_TYPES = ['text' => 'text', 'string' => 'text', 'integer' => 'integer', 'bigint' => 'integer', 'biginteger' => 'integer', 'smallint' => 'integer', 'int' => 'integer', 'decimal' => 'decimal', 'dec' => 'decimal', 'double' => 'decimal', 'float' => 'decimal', 'enum' => 'enum', 'datetime' => 'datetime', 'date' => 'date', 'time' => 'time', 'boolean' => 'boolean', 'bool' => 'boolean', 'tinyint' => 'boolean', 'blob' => 'blob', 'binary' => 'blob', 'bin' => 'blob', 'image' => 'image', 'picture' => 'image']`

Mapping datatye <> Datatype in database. Exampe dec = decimal, float = decimal

### Properties

#### $ajax

SQLManyToOneColumn.php : 33
`public bool $ajax = false`

#### $columnName

SQLManyToOneColumn.php : 23
`public string $columnName = ''`

#### $filterDefinitions

SQLManyToOneColumn.php : 27
`public array<string|int, FilterDefinition> $filterDefinitions = []`

#### $isCustomAjax

SQLColumn.php : 47
`public bool $isCustomAjax = false`

#### $isManyToOne

SQLColumn.php : 45
`public bool $isManyToOne = false`

#### $label

SQLColumn.php : 39
`public string $label = null`

#### $manualInput

SQLManyToOneColumn.php : 31
`public bool $manualInput = false`

#### $name

SQLColumn.php : 38
`public string $name = null`

#### $onLoadCallback

SQLColumn.php : 51
`public callable $onLoadCallback = null`

#### $onSearchCallback

SQLColumn.php : 53
`public callable $onSearchCallback = null`

#### $options

SQLColumn.php : 43
`public array<string|int, mixed> $options = []`

See class description above for options available

#### $pageId

SQLManyToOneColumn.php : 29
`public string $pageId = ''`

#### $secondaryColumnNames

SQLManyToOneColumn.php : 25
`public array<string|int, string> $secondaryColumnNames = []`

#### $toTableName

SQLManyToOneColumn.php : 21
`public string $toTableName = ''`

#### $type

SQLColumn.php : 40
`public string $type = null`

#### $ajaxOptions

SQLColumn.php : 49
`protected AjaxOptions $ajaxOptions = null`

### Methods

#### __construct()

SQLManyToOneColumn.php : 52

Creates a new Many to One Column

`public __construct(string $name, string $label, string $type, string $toTableName, string $columnName[, array<string|int, string> $secondaryColumnNames = [] ][, string $pageId = '' ][, array<string|int, FilterDefinition> $filterDefinitions = [] ][, array<string|int, mixed> $options = [] ][, bool $manualInput = false ][, bool $ajax = false ][, array<string|int, mixed> $ajaxOptions = null ]) : mixed`

##### Parameters

$name : string
$label : string
$type : string

  See Class SQLColumn for types

$toTableName : string

  Curdkit table name

$columnName : string

  Primary relations column

$secondaryColumnNames : array<string|int, string> = []

  Secondary columns which will be shown to the user (more = slower)

$pageId : string = ''

  The drilldown page id

$filterDefinitions : array<string|int, FilterDefinition> = []

  (optional) Array of filter definitions to describe the relation.

$options : array<string|int, mixed> = []

  (optional) See Class SQLColumn for options

$manualInput : bool = false

  Allows the user to input custom data manually (without checking)

$ajax : bool = false

  Ajax powered value selection

$ajaxOptions : array<string|int, mixed> = null

  Options for the ajax

##### Tags

see
  SQLColumn

##### Return values

mixed —

#### getAjaxOptions()

SQLColumn.php : 220
`public getAjaxOptions() : AjaxOptions`

##### Return values

AjaxOptions —

#### getCardUrl()

SQLManyToOneColumn.php : 126

Gets the url to the card page of the related record.

`public getCardUrl(array<string|int, mixed> $record) : string`

##### Parameters

$record : array<string|int, mixed>

  Record data

##### Return values

string —

#### getColumnsForSelect()

SQLManyToOneColumn.php : 145
`public getColumnsForSelect(bool $includeAjaxColumns) : array<string|int, string>`

##### Parameters

$includeAjaxColumns : bool

##### Return values

array<string|int, string> —

#### getManyToOneValues()

SQLManyToOneColumn.php : 84

Gets array of values.

`public getManyToOneValues([array<string|int, mixed> $record = [] ][, bool $onlyCurrentValue = false ]) : array<string|int, mixed>`

Will be shown as

##### Parameters

$record : array<string|int, mixed> = []

  Record data

$onlyCurrentValue : bool = false

##### Return values

array<string|int, mixed> —

#### isHidden()

SQLColumn.php : 175

Checks if the column is hidden (in general or on a specific page type.)

`public isHidden([string $pageType = '' ]) : bool`

##### Parameters

$pageType : string = ''

  Valid page types are: '','list','card','create','update' ('' = all pages)

##### Return values

bool —

#### mapDatatype()

SQLColumn.php : 140

Maps various names for datatypes to a uniform name.

`public static mapDatatype(string $datatype[, string $columnName = '' ]) : string`

`Example: string, text = text` `Example: int, integer, bigint = integer`

##### Parameters

$datatype : string

  The name of the datatype

$columnName : string = ''

  The name of the column for a more precise exception message, if needed.

##### Tags

throws
  Exception

  if $datatype is not recognized as a valid datatype

internal

##### Return values

string —

the uniform datatype name

#### setAjaxOptions()

SQLManyToOneColumn.php : 162
`public setAjaxOptions([AjaxOptions $ajaxOptions = null ]) : void`

##### Parameters

$ajaxOptions : AjaxOptions = null

##### Return values

void —

#### triggerOnLoadEvent()

SQLColumn.php : 192
`public triggerOnLoadEvent(mixed &$value, mixed $record, TableDescriptor $table, PageDescriptor $page, SQLColumn $column) : mixed`

##### Parameters

$value : mixed
$record : mixed
$table : TableDescriptor
$page : PageDescriptor
$column : SQLColumn

##### Return values

mixed —

#### triggerOnSearchEvent()

SQLColumn.php : 199
`public triggerOnSearchEvent(mixed &$results, mixed $input, TableDescriptor $table, PageDescriptor $page, SQLColumn $column) : mixed`

##### Parameters

$results : mixed
$input : mixed
$table : TableDescriptor
$page : PageDescriptor
$column : SQLColumn

##### Return values

mixed —

#### checkOptions()

SQLColumn.php : 158
`private checkOptions() : mixed`

##### Return values

mixed —

## Search results