Jump to content

AtkExpressionAttribute: Difference between revisions

From NusaATK
Sams90 (talk | contribs)
No edit summary
 
Yotmv (talk | contribs)
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{attribute}}
example:
example:


$this->add(new atkExpressionAttribute("employee_count", "SELECT COUNT(*) FROM employee_department ed WHERE ed.department_id = [table].id"));
<syntaxhighlight lang="php">
$this->add(new atkExpressionAttribute("employee_count", "SELECT COUNT(*)  
                                                        FROM employee_department ed
                                                        WHERE ed.department_id = [table].id"));
</syntaxhighlight>


This gives you a nice overview of the number of employees in each department in the admin overview of the department node.
This gives you a nice overview of the number of employees in each department in the admin overview of the department node.


Any SQL expression can be used and you can reference the node's table using the [table] block.
Any SQL expression can be used and you can reference the node's table using the [table] block.
Similarly you can use join's (example below is for MySQL LEFT JOIN) to get information through relations.
Example:
<syntaxhighlight lang="php">
$this->add(new atkExpressionAttribute("widget_count", "SELECT COUNT(*)
                                                        FROM widget wi
                                                        LEFT JOIN widgetBatch wb ON wi.batch_ID=wb.batch_ID
                                                        WHERE wb.name_ID = [table].name_ID"));
</syntaxhighlight>


Note: http://www.achievo.org/forum/viewtopic.php?t=2409&highlight=atkexpressionattribute
Note: http://www.achievo.org/forum/viewtopic.php?t=2409&highlight=atkexpressionattribute

Latest revision as of 19:39, 11 September 2008

Attribute: atkExpressionAttribute

API docs | Flags

List of other attributes

File:AtkExpressionAttribute.png
atkExpressionAttribute screenshot

example:

$this->add(new atkExpressionAttribute("employee_count", "SELECT COUNT(*) 
                                                         FROM employee_department ed
                                                         WHERE ed.department_id = [table].id"));

This gives you a nice overview of the number of employees in each department in the admin overview of the department node.

Any SQL expression can be used and you can reference the node's table using the [table] block.


Similarly you can use join's (example below is for MySQL LEFT JOIN) to get information through relations. Example:

$this->add(new atkExpressionAttribute("widget_count", "SELECT COUNT(*) 
                                                         FROM widget wi 
                                                         LEFT JOIN widgetBatch wb ON wi.batch_ID=wb.batch_ID
                                                         WHERE wb.name_ID = [table].name_ID"));

Note: http://www.achievo.org/forum/viewtopic.php?t=2409&highlight=atkexpressionattribute