Framework  3.9
JoinResult Class Reference

JoinResult is an empty placeholder class. More...

Public Member Functions

 JoinResult ($tag="join")
 
 toXML ($indent=0)
 Serializes the JoinResult to XML. More...
 
 format ($template)
 Formats the contents of the JoinResult using the supplied template. More...
 

Public Attributes

 $_xmlTagName = "join"
 
 $_classes
 

Detailed Description

JoinResult is an empty placeholder class.

Instances of JoinResult are used to aggregate the results of the joined query. Each table that was joined is added as a sub-object of the JoinResult.

Definition at line 45 of file join.inc.

Member Function Documentation

◆ format()

JoinResult::format (   $template)

Formats the contents of the JoinResult using the supplied template.

The DataItems contained in the JoinResult can be accessed via the usual relation traversal syntax {ClassName.field}. This method allows JoinResult objects to be used in DataListViews and other display controls.

Parameters
$templatethe template for the formatted output

Definition at line 85 of file join.inc.

86  {
87  $matches = array();
88 
89  if (count($this->_classes) == 1 && preg_match("/^[\\w_]+/"))
90  {
91  $cl = $this->_classes[0];
92  return $this->$cl->$format;
93  }
94 
95  preg_match_all("/\\{([\\w_]+)\.([^}]+)}/", $template, $matches, PREG_SET_ORDER);
96 
97  foreach($matches as $match)
98  {
99  $class = $match[1];
100  $subtemplate = $match[2];
101 
102  $value = is_object($this->$class) ? $this->$class->format("{".$subtemplate."}") : "";
103 
104  $template = str_replace($match[0], $value, $template);
105  }
106 
107  $matches = array();
108 
109  preg_match_all("/\\{([\\w\\d_]+)::([^}]*)}/", $template, $matches, PREG_SET_ORDER);
110 
111  foreach($matches as $match)
112  {
113  $sub = call_user_func(array($match[1], $match[2]), $this);
114  $template = str_replace($match[0], $sub, $template);
115  }
116 
117  return $template;
118  }

◆ JoinResult()

JoinResult::JoinResult (   $tag = "join")

Definition at line 50 of file join.inc.

51  {
52  $this->_xmlTagName = $tag;
53  $this->_classes = array();
54  }

◆ toXML()

JoinResult::toXML (   $indent = 0)

Serializes the JoinResult to XML.

Parameters
integer$indentthe initial indentation level for the output.

Definition at line 61 of file join.inc.

62  {
63  $xml = str_repeat(" ", $indent) . "<" . $this->_xmlTagName . ">\n";
64  foreach ($this as $field => $val)
65  {
66  if (is_object($val))
67  {
68  $xml .= $val->toXML($indent + 1);
69  }
70  }
71 
72  $xml .= str_repeat(" ", $indent) . "</" . $this->_xmlTagName . ">\n";
73 
74  return $xml;
75  }

Member Data Documentation

◆ $_classes

JoinResult::$_classes

Definition at line 48 of file join.inc.

◆ $_xmlTagName

JoinResult::$_xmlTagName = "join"

Definition at line 47 of file join.inc.


The documentation for this class was generated from the following file: