Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class attribute extends attribute_ext

Hide Inherited MembersHelix Core
Description
No description.
 
Constants
constantTABLENAME ["cor_attribute"][ attribute ]
 
Properties
protected_cdate[ attribute_db ]
protected_cdate_dirty[ attribute_db ]
protected_deleted[ attribute_db ]
protected_deleted_dirty[ attribute_db ]
protected_description[ attribute_db ]
protected_description_dirty[ attribute_db ]
protected_dirty[ obj ]
protected_id[ attribute_db ]
protected_id_dirty[ attribute_db ]
protected_mdate[ attribute_db ]
protected_mdate_dirty[ attribute_db ]
protected_name[ attribute_db ]
protected_name_dirty[ attribute_db ]
publicproperty_objects_array[ obj ]
protected_unit_id[ attribute_db ]
protected_unit_id_dirty[ attribute_db ]
protected_value[ attribute_db ]
protected_value_dirty[ attribute_db ]
 
Methods
publiccommit ( )[ attribute_db ]
Parameters
No parameters for this method
Code
104  public function commit()
105  {
106      if ($this->_id > 0)
107      {
108          $this->update();
109      }
110      else
111      {
112          $this->insert();
113      }
114 
115      foreach ($this->property_objects_array as $property=>$object)
116      {
117          $this->{$property} = $object;
118      }
119 
120      return true;
121  }
public__construct ( id )[ attribute_db ]
Parameters
optionalid
Code
046  public function __construct($__id=null)
047  {
048      $this->_id = 0;
049      $this->_name = "";
050      $this->_description = "";
051      $this->_value = "";
052      $this->_unit_id = 0;
053      $this->_mdate = null;
054      $this->_cdate = null;
055      $this->_deleted = false;
056 
057      $this->_id_dirty = false;
058      $this->_name_dirty = false;
059      $this->_description_dirty = false;
060      $this->_value_dirty = false;
061      $this->_unit_id_dirty = false;
062      $this->_mdate_dirty = false;
063      $this->_cdate_dirty = false;
064      $this->_deleted_dirty = false;
065 
066      if (is_null($__id))
067      {
068          return;
069      }
070 
071      $db = attribute::db();
072      $q  = " SELECT cor_attribute.id,cor_attribute.name,cor_attribute.description,cor_attribute.value,cor_attribute.unit_id,cor_attribute.mdate,cor_attribute.cdate,cor_attribute.deleted ";
073      $q .= " FROM cor_attribute ";       
074      if (!is_null($__id))
075      {
076          $q .= " WHERE id = '$__id' ";
077      }
078 
079      $db->query($q);
080      if ($db->next_record() && $db->num_rows() == 1)
081      {
082          $this->_id = $db->f("id");
083          $this->_name = $db->f("name");
084          $this->_description = $db->f("description");
085          $this->_value = $db->f("value");
086          $this->_unit_id = $db->f("unit_id");
087          $this->_mdate = $db->f("mdate");
088          $this->_cdate = $db->f("cdate");
089          $this->_deleted = $db->f("deleted");
090      }
091  }
protected staticdb ( )[ attribute_db ]
Parameters
No parameters for this method
Code
444  protected static function db()
445  {
446      return new db();
447  }
publicdelete ( )[ attribute_db ]
Parameters
No parameters for this method
Code
163  public function delete()
164  {
165      $db = attribute::db();
166      $q  = " UPDATE cor_attribute SET ";
167      $q .= " deleted = 1 ";
168      $q .= " WHERE id = " . $this->_id;
169      $db->query($q);
170      $this->deleted = true;
171      return true;
172  }
public staticdelete_all ( )[ attribute_db ]
Parameters
No parameters for this method
Code
270  public static function delete_all()
271  {
272      $db = attribute::db();
273      $q  = " UPDATE cor_attribute SET ";
274      $q .= " deleted = 1 ";
275     
276      $db->query($q);
277      return true;
278  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
public staticget_columns ( columns , order , lookups , where_clause , limit , offset [0] )[ attribute_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
194  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
195  {
196      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
197      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
198      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
199 
200      $db = attribute::db();
201      $data = array();
202      $q  = " SELECT $colstring ";
203      $q .= " FROM cor_attribute ";
204      $q .= " WHERE cor_attribute.deleted = 0 ";
205      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
206      $q .= array_key_exists("unit_id",$lookups) ? " AND cor_attribute.unit_id='" . $lookups["unit_id"] . "' " : "";
207 
208      if (is_string($__order))
209      {
210          $q .= "ORDER BY " . $__order;
211      }
212      else if (is_array($__order) and count($__order)>0)
213      {
214          $orderings = array();
215          foreach ($__order as $col=>$dir)
216          {
217              $orderings[] = " $col $dir ";
218          }
219          $q .= "ORDER BY " . implode(", ", $orderings);
220      }
221      else if (is_object($__order))
222      {
223          $q .= "";
224      }
225      else
226      {
227          // THERE IS NO `order` COLUMN ON THIS OBJECT
228      }
229 
230      if (!is_null($__limit))
231      {
232          $q .= " LIMIT $__offset , $__limit ";
233      }
234 
235      $db->query($q);
236 
237      if (count($colarray)>1 || $colstring=="*")
238      {
239          while ($db->next_record())
240          {
241              $data[] = $db->record;
242          }
243      }
244      else
245      {
246          while ($db->next_record())
247          {
248              $data[] = $db->f(0);
249          }
250      }
251 
252      return $data;
253  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ attribute_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
255  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
256  {
257      return attribute::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
258  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
public staticget_objects ( order , lookups , where_clause , limit , offset [0] )[ attribute_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
260  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
261  {
262      $objects = array();
263      foreach (attribute::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
264      {
265          $objects[] = new attribute($id);
266      }
267      return $objects;
268  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_report ( type ["default"] )[ attribute_db ]
Parameters
optionaltype ["default"]
Code
345  public function get_report($__type="default")
346  {
347      $object = is_null(keyval($this->property_objects_array,"{$__type}_report")) ? new report($this->get_report_id($__type)) : $this->property_objects_array["{$__type}_report"];
348      $this->property_objects_array["{$__type}_report"] = $object;
349      return $object;
350  }
publicget_report_id ( type ["default"] )[ attribute_db ]
Parameters
optionaltype ["default"]
Code
351  public function get_report_id($__type="default")
352  {
353      $ids = $this->get_report_ids($__type, true);
354      return (count($ids)==1 ? $ids[0] : null);
355  }
publicget_report_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ attribute_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
356  public function get_report_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
357  {
358      $report_ids = array();
359      $db = attribute::db();
360      $q  = " SELECT rpt_report.id FROM rpt_attribute_report INNER JOIN rpt_report ON rpt_attribute_report.report_id=rpt_report.id AND rpt_attribute_report.deleted=0 AND rpt_report.deleted=0 AND rpt_attribute_report.attribute_id='$this->id' " . (is_null($__type) ? "" : " AND rpt_attribute_report.attribute_report_type_id='" . attribute_report::type_id($__type) . "'") . ($__get_primary ? " AND rpt_attribute_report.primary=1 " : "");
361      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
362      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
363      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
364      $db->query($q);
365      while ($db->next_record())
366      {
367          $report_ids[] = $db->f("id");
368      }
369      return $report_ids;
370  }
publicget_report_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ attribute_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
371  public function get_report_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
372  {
373      $ids = $this->get_report_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
374      $objects = array();
375      foreach ($ids as $index=>$id)
376      {
377          $objects[$index] = new report($id);
378      }
379      return $objects;
380  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicget_unit ( )[ attribute_db ]
Parameters
No parameters for this method
Code
333  public function get_unit()
334  {
335      return new unit($this->unit_id);
336  }
protectedinsert ( )[ attribute_db ]
Parameters
No parameters for this method
Code
123  protected function insert()
124  {
125      $db = attribute::db();
126      $q  = " INSERT INTO cor_attribute ( ";
127      $q .= $db->param_string("name") . ", ";
128      $q .= $db->param_string("description") . ", ";
129      $q .= $db->param_string("value") . ", ";
130      $q .= $db->param_string("unit_id") . ", ";
131      $q .= $db->param_string("mdate") . ", ";
132      $q .= $db->param_string("cdate") . ", ";
133      $q .= $db->param_string("deleted");
134      $q .= " ) VALUES ( ";
135      $q .= $db->value_string($this->_name) . ", ";
136      $q .= $db->value_string($this->_description) . ", ";
137      $q .= $db->value_string($this->_value) . ", ";
138      $q .= $db->value_string($this->_unit_id) . ", ";
139      $q .= $db->value_string(timestamp()) . ", ";
140      $q .= $db->value_string(timestamp()) . ", ";
141      $q .= $this->deleted ? "'1'" : "'0'";
142      $q .= " ) ";
143      $db->query($q);
144      $this->_id = $db->insert_id;
145      return true;
146  }
publicmap ( )[ attribute_db ]
Parameters
No parameters for this method
Code
093  public function map()
094  {
095      $this->_name = array_key_exists("attribute:name",$_REQUEST) ? reqval("attribute:name") : $this->_name;
096      $this->_description = array_key_exists("attribute:description",$_REQUEST) ? reqval("attribute:description") : $this->_description;
097      $this->_value = array_key_exists("attribute:value",$_REQUEST) ? reqval("attribute:value") : $this->_value;
098      $this->_unit_id = array_key_exists("attribute:unit_id",$_REQUEST) ? reqval("attribute:unit_id") : $this->_unit_id;
099      $this->_mdate = array_key_exists("attribute:mdate",$_REQUEST) ? reqval("attribute:mdate") : $this->_mdate;
100      $this->_cdate = array_key_exists("attribute:cdate",$_REQUEST) ? reqval("attribute:cdate") : $this->_cdate;
101      $this->_deleted = array_key_exists("attribute:deleted",$_REQUEST) ? reqval("attribute:deleted") : $this->_deleted;
102  }
publicpurge ( )[ attribute_db ]
Parameters
No parameters for this method
Code
185  public function purge()
186  {
187      $db = attribute::db();
188      $q  = " DELETE FROM cor_attribute ";
189      $q .= " WHERE id = " . $this->_id;
190      $db->query($q);
191      return true;
192  }
public staticsearch ( keyword )[ attribute_db ]
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
publicset_report ( v , type ["default"] )[ attribute_db ]
Parameters
requiredv
optionaltype ["default"]
Code
382  public function set_report($__v, $__type="default")
383  {
384      $object = is_null(keyval($this->property_objects_array,"{$__type}_report")) ? new report($this->get_report_id($__type)) : $this->property_objects_array["{$__type}_report"];
385      if (is_null($__v))
386      {
387          $rel = new attribute_report(null,$this->id,$object->id,attribute_report::type_id($__type));
388          $rel->delete();
389          if (!is_null(keyval($this->property_objects_array,"{$__type}_report")))
390          {
391              $this->property_objects_array["{$__type}_report"] = null;
392          }
393      }
394      else
395      {
396          $id = $object->id;
397          $object = $__v;
398          $object->id = $__v->id>0 ? $__v->id : $id;
399          $object->commit();
400          $this->set_report_ids(array($object->id),$__type);
401      }
402  }
publicset_report_id ( v , type ["default"] )[ attribute_db ]
Parameters
requiredv
optionaltype ["default"]
Code
403  public function set_report_id($__v, $__type="default")
404  {
405      $this->set_report_ids(array($__v),$__type);
406  }
publicset_report_ids ( v , type ["default"] )[ attribute_db ]
Parameters
requiredv
optionaltype ["default"]
Code
407  public function set_report_ids($__v, $__type="default")
408  {
409      if ($this->id == 0)
410      {
411          $this->commit();
412      }
413      $type_id = attribute_report::type_id($__type);
414      attribute_report::delete_all($this->id,null,$type_id);
415      if (is_array($__v))
416      {
417          foreach ($__v as $index=>$id)
418          {
419              $object = new attribute_report(null,$this->id,$id,$type_id);
420              $object->deleted = false;
421              $object->attribute_report_type_id = $type_id;
422              $object->commit();
423              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_report")))
424              {
425                  $this->property_objects_array["{$__type}_report"] = new report($object->report_id);
426              }
427          }
428          $this->_dirty = true;
429      }
430  }
publicset_report_list ( v , type ["default"] )[ attribute_db ]
Parameters
requiredv
optionaltype ["default"]
Code
431  public function set_report_list($__v, $__type="default")
432  {
433      if (is_array($__v))
434      {
435          $ids = array();
436          foreach ($__v as $index=>$object)
437          {
438              $ids[] = $object->id;
439          }
440          $this->set_report_ids($ids,$__type);
441      }
442  }
publicset_unit ( v )[ attribute_db ]
Parameters
requiredv
Code
337  public function set_unit($v)
338  {
339      if ($v->id > 0)
340      {
341          $this->unit_id = $v->id;
342      }
343  }
public__toString ( )[ attribute_db ]
Parameters
No parameters for this method
Code
328  public function __toString()
329  {
330      return (is_null($this->name) ? "" : $this->name);
331  }
publicundelete ( )[ attribute_db ]
Parameters
No parameters for this method
Code
174  public function undelete()
175  {
176      $db = attribute::db();
177      $q  = " UPDATE cor_attribute SET ";
178      $q .= " deleted = 0 ";
179      $q .= " WHERE id = " . $this->_id;
180      $db->query($q);
181      $this->deleted = false;
182      return true;
183  }
protectedupdate ( )[ attribute_db ]
Parameters
No parameters for this method
Code
148  protected function update()
149  {
150      $db = attribute::db();
151      $q  = " UPDATE cor_attribute SET ";
152      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
153      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
154      $q .= $db->param_string("value") . " = " . $db->value_string($this->_value) . ", ";
155      $q .= $db->param_string("unit_id") . " = " . $db->value_string($this->_unit_id) . ", ";
156      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
157      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
158      $q .= " WHERE id = " . $this->_id;
159      $db->query($q);
160      return true;
161  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ attribute_db ]
Code
194  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
195  {
196      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
197      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
198      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
199 
200      $db = attribute::db();
201      $data = array();
202      $q  = " SELECT $colstring ";
203      $q .= " FROM cor_attribute ";
204      $q .= " WHERE cor_attribute.deleted = 0 ";
205      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
206      $q .= array_key_exists("unit_id",$lookups) ? " AND cor_attribute.unit_id='" . $lookups["unit_id"] . "' " : "";
207 
208      if (is_string($__order))
209      {
210          $q .= "ORDER BY " . $__order;
211      }
212      else if (is_array($__order) and count($__order)>0)
213      {
214          $orderings = array();
215          foreach ($__order as $col=>$dir)
216          {
217              $orderings[] = " $col $dir ";
218          }
219          $q .= "ORDER BY " . implode(", ", $orderings);
220      }
221      else if (is_object($__order))
222      {
223          $q .= "";
224      }
225      else
226      {
227          // THERE IS NO `order` COLUMN ON THIS OBJECT
228      }
229 
230      if (!is_null($__limit))
231      {
232          $q .= " LIMIT $__offset , $__limit ";
233      }
234 
235      $db->query($q);
236 
237      if (count($colarray)>1 || $colstring=="*")
238      {
239          while ($db->next_record())
240          {
241              $data[] = $db->record;
242          }
243      }
244      else
245      {
246          while ($db->next_record())
247          {
248              $data[] = $db->f(0);
249          }
250      }
251 
252      return $data;
253  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicids[ attribute_db ]
Code
255  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
256  {
257      return attribute::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
258  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicobjects[ attribute_db ]
Code
260  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
261  {
262      $objects = array();
263      foreach (attribute::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
264      {
265          $objects[] = new attribute($id);
266      }
267      return $objects;
268  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicreport[ attribute_db ]
Code
345  public function get_report($__type="default")
346  {
347      $object = is_null(keyval($this->property_objects_array,"{$__type}_report")) ? new report($this->get_report_id($__type)) : $this->property_objects_array["{$__type}_report"];
348      $this->property_objects_array["{$__type}_report"] = $object;
349      return $object;
350  }
Code
382  public function set_report($__v, $__type="default")
383  {
384      $object = is_null(keyval($this->property_objects_array,"{$__type}_report")) ? new report($this->get_report_id($__type)) : $this->property_objects_array["{$__type}_report"];
385      if (is_null($__v))
386      {
387          $rel = new attribute_report(null,$this->id,$object->id,attribute_report::type_id($__type));
388          $rel->delete();
389          if (!is_null(keyval($this->property_objects_array,"{$__type}_report")))
390          {
391              $this->property_objects_array["{$__type}_report"] = null;
392          }
393      }
394      else
395      {
396          $id = $object->id;
397          $object = $__v;
398          $object->id = $__v->id>0 ? $__v->id : $id;
399          $object->commit();
400          $this->set_report_ids(array($object->id),$__type);
401      }
402  }
publicreport_id[ attribute_db ]
Code
351  public function get_report_id($__type="default")
352  {
353      $ids = $this->get_report_ids($__type, true);
354      return (count($ids)==1 ? $ids[0] : null);
355  }
Code
403  public function set_report_id($__v, $__type="default")
404  {
405      $this->set_report_ids(array($__v),$__type);
406  }
publicreport_ids[ attribute_db ]
Code
356  public function get_report_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
357  {
358      $report_ids = array();
359      $db = attribute::db();
360      $q  = " SELECT rpt_report.id FROM rpt_attribute_report INNER JOIN rpt_report ON rpt_attribute_report.report_id=rpt_report.id AND rpt_attribute_report.deleted=0 AND rpt_report.deleted=0 AND rpt_attribute_report.attribute_id='$this->id' " . (is_null($__type) ? "" : " AND rpt_attribute_report.attribute_report_type_id='" . attribute_report::type_id($__type) . "'") . ($__get_primary ? " AND rpt_attribute_report.primary=1 " : "");
361      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
362      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
363      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
364      $db->query($q);
365      while ($db->next_record())
366      {
367          $report_ids[] = $db->f("id");
368      }
369      return $report_ids;
370  }
Code
407  public function set_report_ids($__v, $__type="default")
408  {
409      if ($this->id == 0)
410      {
411          $this->commit();
412      }
413      $type_id = attribute_report::type_id($__type);
414      attribute_report::delete_all($this->id,null,$type_id);
415      if (is_array($__v))
416      {
417          foreach ($__v as $index=>$id)
418          {
419              $object = new attribute_report(null,$this->id,$id,$type_id);
420              $object->deleted = false;
421              $object->attribute_report_type_id = $type_id;
422              $object->commit();
423              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_report")))
424              {
425                  $this->property_objects_array["{$__type}_report"] = new report($object->report_id);
426              }
427          }
428          $this->_dirty = true;
429      }
430  }
publicreport_list[ attribute_db ]
Code
371  public function get_report_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
372  {
373      $ids = $this->get_report_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
374      $objects = array();
375      foreach ($ids as $index=>$id)
376      {
377          $objects[$index] = new report($id);
378      }
379      return $objects;
380  }
Code
431  public function set_report_list($__v, $__type="default")
432  {
433      if (is_array($__v))
434      {
435          $ids = array();
436          foreach ($__v as $index=>$object)
437          {
438              $ids[] = $object->id;
439          }
440          $this->set_report_ids($ids,$__type);
441      }
442  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicunit[ attribute_db ]
Code
333  public function get_unit()
334  {
335      return new unit($this->unit_id);
336  }
Code
337  public function set_unit($v)
338  {
339      if ($v->id > 0)
340      {
341          $this->unit_id = $v->id;
342      }
343  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads