class \mpf\datasources\sql\DbRelation

class \mpf\datasources\sql\DbRelation

-no description found-

Attributes
public mixed $name

-no description found-

public mixed $type

-no description found-

public mixed $model

-no description found-

public mixed $conditions = []

-no description found-

public mixed $joins = []

-no description found-

public string $joinType = "LEFT JOIN"

-no description found-

public mixed $order

-no description found-

public mixed $offset

-no description found-

public mixed $limit

-no description found-

public string $tableAlias

-no description found-

public string $tableName

-no description found-

protected mixed $_lastConditionParams = []

-no description found-

Methods

public static \mpf\datasources\sql\DbRelation belongsTo (string $model, string $parentColumn)

  • $model

    -no description found-

  • $parentColumn

    -no description found-

Creates new belongsTo Relation

public static \mpf\datasources\sql\DbRelation hasOne (string $model)

  • $model

    -no description found-

Creates new hasOne relation

public static \mpf\datasources\sql\DbRelation hasMany (string $model)

  • $model

    -no description found-

Creates new hasMany relation

public static \mpf\datasources\sql\DbRelation manyToMany (string $model)

  • $model

    -no description found-

Creates new manyToMany relation

public bool isRequiredForCount ()

Checks if relation is required for count.

public \mpf\datasources\sql\DbRelation setName (string $name)

  • $name

    -no description found-

-no description found-

public \mpf\datasources\sql\DbRelation columnsEqual (string $modelColumn, string $relationColumn)

  • $modelColumn

    If a list of two or more columns is sent then it will compare c2 with this list. From main model

  • $relationColumn

    If a list of two or more columns is sent then it will compare c1 with this list. From relation

Set a conditions that those two columns must be equal. Also when it searches relations for more models it will automatically change it in a "in" condition. If another table or relation is used and some column can't be from model or relation then it can be sent as "otherTableOrAlias.column"

public \mpf\datasources\sql\DbRelation columnsDifferent (string $modelColumn, string $relationColumn)

  • $modelColumn

    -no description found-

  • $relationColumn

    -no description found-

Same as columnsEqual but it will make sure that they are different.(/ NOT IN)

public \mpf\datasources\sql\DbRelation hasValue (string $relationColumn, string $value)

  • $relationColumn

    -no description found-

  • $value

    -no description found-

It will compare selected column with the exact given value.

public \mpf\datasources\sql\DbRelation hasAttributeValue (string $column, string $modelAttribute)

  • $column

    -no description found-

  • $modelAttribute

    can also be a method. In that case must end with () so that the script knows to call it as a method

It will compare the selected column with the value that model static attribute has at that time. That attribute must be static(so that if it has to read from multiple modules it won't check the value for each of them)

public \mpf\datasources\sql\DbRelation setJoinType (string $type)

  • $type

    -no description found-

Change join type

public \mpf\datasources\sql\DbRelation orderBy (mixed $order)

  • $order

    -no description found-

-no description found-

public \mpf\datasources\sql\DbRelation offset (mixed $offset)

  • $offset

    -no description found-

-no description found-

public \mpf\datasources\sql\DbRelation limit (mixed $limit)

  • $limit

    -no description found-

-no description found-

public \mpf\datasources\sql\DbRelation join (string $tableName, string[] $columnsCompare, string[] $valueCompare = [], string $type = "LEFT JOIN")

  • $tableName

    Can be string "tableName" or [tableName=>tableAlias]

  • $columnsCompare

    a list of columns to compare, example: ["t.c1" => "joinTable.c2"]

  • $valueCompare

    a list of columns with exact values to compare. ["t.c1" => "value"]

  • $type

    type of join for this table

Creates an extra join with a new table that doesn't require a model.

public mixed hasSingleResult ()

-no description found-

public string getWithParent (\mpf\datasources\sql\DbModel $parentModel, string $fullName = "t")

  • $parentModel

    -no description found-

  • $fullName

    -no description found-

-no description found-

public string getCondition (string $parentModel, string $fullName)

  • $parentModel

    -no description found-

  • $fullName

    -no description found-

-no description found-

public array getConditionParams ()

Returns params created by last condition;

protected string getColumnEqualWithParent (string[] $condition, string $parentModel, string $fullName)

  • $condition

    -no description found-

  • $parentModel

    -no description found-

  • $fullName

    -no description found-

Creates string condition from known data

protected mixed _column (mixed $name, mixed $fromParent = false, mixed $fullName = "t")

  • $name

    -no description found-

  • $fromParent

    -no description found-

  • $fullName

    -no description found-

-no description found-

public string getRelationTableForJoin (string $fullName)

  • $fullName

    -no description found-

Get table from relation join. Also calculates tableAlias;

public \mpf\datasources\sql\ModelCondition getConditionForModel (\mpf\datasources\sql\DbModel $model)

  • $model

    -no description found-

Return condition for select for a single model;

public \mpf\datasources\sql\ModelCondition getConditionForModels (\mpf\datasources\sql\DbModel[] $models, string $fields)

  • $models

    -no description found-

  • $fields

    -no description found-

-no description found-

public string getTableAlias ()

-no description found-

public string getTableName ()

-no description found-