PHP Class Field_Expression, atk4

Field_Expression implements ability to specify expressions inside your SQL_Model and have them appear as a read-only fields. Use: $model->addExpression('age','year(now())-year(birthdate)'); Below example achieves the same,but it prefixes age with proper table name $model->addExpression('age', 'year(now())-year('.$model->getElement('adatege').')'); $model->addExpression('row_counter',$this->db->dsql()->useExpr('@x := @x+1'); using custom controller to format field $myctl=$this->add('Controller_MiscMySQL'); $model->addExpression('date_formatted',array($myctl,'dateExpr1')); or or by using closure and extra argument $myctl=$this->add('Controller_MiscMySQL'); $model->addExpression('date_formatted', function($model,$query) uses $myctl { return $myctl->dateExpr2($query,'date_raw'); }); NOTE: MiscMySQL is fictional controller.
Inheritance: extends Field
Mostrar archivo Open project: atk4/atk4

Public Properties

Property Type Description
$expr

Public Methods

Method Description
calculated ( $x = UNDEFINED )
editable ( $x = UNDEFINED )
getExpr ( )
set ( $expr = null ) specify DSQL, String or function($model, $dsql, $this_field)
updateInsertQuery ( $insert )
updateModifyQuery ( $insert )
updateSelectQuery ( $select )

Method Details

calculated() public method

public calculated ( $x = UNDEFINED )

editable() public method

public editable ( $x = UNDEFINED )

getExpr() public method

public getExpr ( )

set() public method

specify DSQL, String or function($model, $dsql, $this_field)
public set ( $expr = null )

updateInsertQuery() public method

public updateInsertQuery ( $insert )

updateModifyQuery() public method

public updateModifyQuery ( $insert )

updateSelectQuery() public method

public updateSelectQuery ( $select )

Property Details

$expr public_oe property

public $expr