Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class querygroup extends querygroup_ext

Hide Inherited MembersForm Builder
Description
No description.
 
Constants
constantTABLENAME ["qi_querygroup"][ querygroup ]
 
Properties
protected_cdate[ querygroup_db ]
protected_cdate_dirty[ querygroup_db ]
protected_deleted[ querygroup_db ]
protected_deleted_dirty[ querygroup_db ]
protected_description[ querygroup_db ]
protected_description_dirty[ querygroup_db ]
protected_dirty[ obj ]
protected_footer[ querygroup_db ]
protected_footer_dirty[ querygroup_db ]
protected_header[ querygroup_db ]
protected_header_dirty[ querygroup_db ]
protected_id[ querygroup_db ]
protected_id_dirty[ querygroup_db ]
protected_mdate[ querygroup_db ]
protected_mdate_dirty[ querygroup_db ]
protected_name[ querygroup_db ]
protected_name_dirty[ querygroup_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
108  public function commit()
109  {
110      if ($this->_id > 0)
111      {
112          $this->update();
113      }
114      else
115      {
116          $this->insert();
117      }
118 
119      foreach ($this->property_objects_array as $property=>$object)
120      {
121          $this->{$property} = $object;
122      }
123 
124      return true;
125  }
public__construct ( id , name )[ querygroup_db ]
Parameters
optionalid
optionalname
Code
046  public function __construct($__id=null, $__name=null)
047  {
048      $this->_id = 0;
049      $this->_name = $__name;
050      $this->_description = "";
051      $this->_header = "";
052      $this->_footer = "";
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->_header_dirty = false;
061      $this->_footer_dirty = false;
062      $this->_mdate_dirty = false;
063      $this->_cdate_dirty = false;
064      $this->_deleted_dirty = false;
065 
066      if (is_null($__id) && is_null($__name))
067      {
068          return;
069      }
070 
071      $db = querygroup::db();
072      $q  = " SELECT qi_querygroup.id,qi_querygroup.name,qi_querygroup.description,qi_querygroup.header,qi_querygroup.footer,qi_querygroup.mdate,qi_querygroup.cdate,qi_querygroup.deleted ";
073      $q .= " FROM qi_querygroup ";       
074      if (!is_null($__id))
075      {
076          $q .= " WHERE id = '$__id' ";
077      }
078      else if (!is_null($__name))
079      {
080          $q .= " WHERE name = '$__name' ";
081      }
082 
083      $db->query($q);
084      if ($db->next_record() && $db->num_rows() == 1)
085      {
086          $this->_id = $db->f("id");
087          $this->_name = $db->f("name");
088          $this->_description = $db->f("description");
089          $this->_header = $db->f("header");
090          $this->_footer = $db->f("footer");
091          $this->_mdate = $db->f("mdate");
092          $this->_cdate = $db->f("cdate");
093          $this->_deleted = $db->f("deleted");
094      }
095  }
protected staticdb ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
437  protected static function db()
438  {
439      return new db();
440  }
publicdelete ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
167  public function delete()
168  {
169      $db = querygroup::db();
170      $q  = " UPDATE qi_querygroup SET ";
171      $q .= " deleted = 1 ";
172      $q .= " WHERE id = " . $this->_id;
173      $db->query($q);
174      $this->deleted = true;
175      return true;
176  }
public staticdelete_all ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
273  public static function delete_all()
274  {
275      $db = querygroup::db();
276      $q  = " UPDATE qi_querygroup SET ";
277      $q .= " deleted = 1 ";
278     
279      $db->query($q);
280      return true;
281  }
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] )[ querygroup_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
198  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
199  {
200      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
201      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
202      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
203 
204      $db = querygroup::db();
205      $data = array();
206      $q  = " SELECT $colstring ";
207      $q .= " FROM qi_querygroup ";
208      $q .= " WHERE qi_querygroup.deleted = 0 ";
209      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
210 
211      if (is_string($__order))
212      {
213          $q .= "ORDER BY " . $__order;
214      }
215      else if (is_array($__order) and count($__order)>0)
216      {
217          $orderings = array();
218          foreach ($__order as $col=>$dir)
219          {
220              $orderings[] = " $col $dir ";
221          }
222          $q .= "ORDER BY " . implode(", ", $orderings);
223      }
224      else if (is_object($__order))
225      {
226          $q .= "";
227      }
228      else
229      {
230          // THERE IS NO `order` COLUMN ON THIS OBJECT
231      }
232 
233      if (!is_null($__limit))
234      {
235          $q .= " LIMIT $__offset , $__limit ";
236      }
237 
238      $db->query($q);
239 
240      if (count($colarray)>1 || $colstring=="*")
241      {
242          while ($db->next_record())
243          {
244              $data[] = $db->record;
245          }
246      }
247      else
248      {
249          while ($db->next_record())
250          {
251              $data[] = $db->f(0);
252          }
253      }
254 
255      return $data;
256  }
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] )[ querygroup_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
258  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
259  {
260      return querygroup::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
261  }
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] )[ querygroup_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
263  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
264  {
265      $objects = array();
266      foreach (querygroup::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
267      {
268          $objects[] = new querygroup($id);
269      }
270      return $objects;
271  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_queryset ( type ["default"] )[ querygroup_db ]
Parameters
optionaltype ["default"]
Code
336  public function get_queryset($__type="default")
337  {
338      $object = is_null(keyval($this->property_objects_array,"{$__type}_queryset")) ? new queryset($this->get_queryset_id($__type)) : $this->property_objects_array["{$__type}_queryset"];
339      $this->property_objects_array["{$__type}_queryset"] = $object;
340      return $object;
341  }
publicget_queryset_id ( type ["default"] )[ querygroup_db ]
Parameters
optionaltype ["default"]
Code
342  public function get_queryset_id($__type="default")
343  {
344      $ids = $this->get_queryset_ids($__type, true);
345      return (count($ids)==1 ? $ids[0] : null);
346  }
publicget_queryset_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ querygroup_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
347  public function get_queryset_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
348  {
349      $queryset_ids = array();
350      $db = querygroup::db();
351      $q  = " SELECT qi_queryset.id FROM qi_querygroup_queryset INNER JOIN qi_queryset ON qi_querygroup_queryset.queryset_id=qi_queryset.id AND qi_querygroup_queryset.deleted=0 AND qi_queryset.deleted=0 AND qi_querygroup_queryset.querygroup_id='$this->id' " . (is_null($__type) ? "" : " AND qi_querygroup_queryset.querygroup_queryset_type_id='" . querygroup_queryset::type_id($__type) . "'") . ($__get_primary ? " AND qi_querygroup_queryset.primary=1 " : "");
352      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
353      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
354      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
355      $db->query($q);
356      while ($db->next_record())
357      {
358          $queryset_ids[] = $db->f("id");
359      }
360      return $queryset_ids;
361  }
publicget_queryset_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ querygroup_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
362  public function get_queryset_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
363  {
364      $ids = $this->get_queryset_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
365      $objects = array();
366      foreach ($ids as $index=>$id)
367      {
368          $objects[$index] = new queryset($id);
369      }
370      return $objects;
371  }
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  }
protectedinsert ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
127  protected function insert()
128  {
129      $db = querygroup::db();
130      $q  = " INSERT INTO qi_querygroup ( ";
131      $q .= $db->param_string("name") . ", ";
132      $q .= $db->param_string("description") . ", ";
133      $q .= $db->param_string("header") . ", ";
134      $q .= $db->param_string("footer") . ", ";
135      $q .= $db->param_string("mdate") . ", ";
136      $q .= $db->param_string("cdate") . ", ";
137      $q .= $db->param_string("deleted");
138      $q .= " ) VALUES ( ";
139      $q .= $db->value_string($this->_name) . ", ";
140      $q .= $db->value_string($this->_description) . ", ";
141      $q .= $db->value_string($this->_header) . ", ";
142      $q .= $db->value_string($this->_footer) . ", ";
143      $q .= $db->value_string(timestamp()) . ", ";
144      $q .= $db->value_string(timestamp()) . ", ";
145      $q .= $this->deleted ? "'1'" : "'0'";
146      $q .= " ) ";
147      $db->query($q);
148      $this->_id = $db->insert_id;
149      return true;
150  }
publicmap ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
097  public function map()
098  {
099      $this->_name = array_key_exists("querygroup:name",$_REQUEST) ? reqval("querygroup:name") : $this->_name;
100      $this->_description = array_key_exists("querygroup:description",$_REQUEST) ? reqval("querygroup:description") : $this->_description;
101      $this->_header = array_key_exists("querygroup:header",$_REQUEST) ? reqval("querygroup:header") : $this->_header;
102      $this->_footer = array_key_exists("querygroup:footer",$_REQUEST) ? reqval("querygroup:footer") : $this->_footer;
103      $this->_mdate = array_key_exists("querygroup:mdate",$_REQUEST) ? reqval("querygroup:mdate") : $this->_mdate;
104      $this->_cdate = array_key_exists("querygroup:cdate",$_REQUEST) ? reqval("querygroup:cdate") : $this->_cdate;
105      $this->_deleted = array_key_exists("querygroup:deleted",$_REQUEST) ? reqval("querygroup:deleted") : $this->_deleted;
106  }
publicpurge ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
189  public function purge()
190  {
191      $db = querygroup::db();
192      $q  = " DELETE FROM qi_querygroup ";
193      $q .= " WHERE id = " . $this->_id;
194      $db->query($q);
195      return true;
196  }
public staticsearch ( keyword )[ querygroup_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_queryset ( v , type ["default"] )[ querygroup_db ]
Parameters
requiredv
optionaltype ["default"]
Code
373  public function set_queryset($__v, $__type="default")
374  {
375      $object = is_null(keyval($this->property_objects_array,"{$__type}_queryset")) ? new queryset($this->get_queryset_id($__type)) : $this->property_objects_array["{$__type}_queryset"];
376      if (is_null($__v))
377      {
378          $rel = new querygroup_queryset(null,$this->id,$object->id,querygroup_queryset::type_id($__type));
379          $rel->delete();
380          if (!is_null(keyval($this->property_objects_array,"{$__type}_queryset")))
381          {
382              $this->property_objects_array["{$__type}_queryset"] = null;
383          }
384      }
385      else
386      {
387          $id = $object->id;
388          $object = $__v;
389          $object->id = $__v->id>0 ? $__v->id : $id;
390          $object->commit();
391          $this->set_queryset_ids(array($object->id),$__type);
392      }
393  }
publicset_queryset_id ( v , type ["default"] )[ querygroup_db ]
Parameters
requiredv
optionaltype ["default"]
Code
394  public function set_queryset_id($__v, $__type="default")
395  {
396      $this->set_queryset_ids(array($__v),$__type);
397  }
publicset_queryset_ids ( v , type ["default"] )[ querygroup_db ]
Parameters
requiredv
optionaltype ["default"]
Code
398  public function set_queryset_ids($__v, $__type="default")
399  {
400      if ($this->id == 0)
401      {
402          $this->commit();
403      }
404      $type_id = querygroup_queryset::type_id($__type);
405      querygroup_queryset::delete_all($this->id,null,$type_id);
406      $order = 0;
407      if (is_array($__v))
408      {
409          foreach ($__v as $index=>$id)
410          {
411              $object = new querygroup_queryset(null,$this->id,$id,$type_id);
412              $object->deleted = false;
413              $object->order = (++$order);
414              $object->querygroup_queryset_type_id = $type_id;
415              $object->commit();
416              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_queryset")))
417              {
418                  $this->property_objects_array["{$__type}_queryset"] = new queryset($object->queryset_id);
419              }
420          }
421          $this->_dirty = true;
422      }
423  }
publicset_queryset_list ( v , type ["default"] )[ querygroup_db ]
Parameters
requiredv
optionaltype ["default"]
Code
424  public function set_queryset_list($__v, $__type="default")
425  {
426      if (is_array($__v))
427      {
428          $ids = array();
429          foreach ($__v as $index=>$object)
430          {
431              $ids[] = $object->id;
432          }
433          $this->set_queryset_ids($ids,$__type);
434      }
435  }
public__toString ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
331  public function __toString()
332  {
333      return (is_null($this->name) ? "" : $this->name);
334  }
publicundelete ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
178  public function undelete()
179  {
180      $db = querygroup::db();
181      $q  = " UPDATE qi_querygroup SET ";
182      $q .= " deleted = 0 ";
183      $q .= " WHERE id = " . $this->_id;
184      $db->query($q);
185      $this->deleted = false;
186      return true;
187  }
protectedupdate ( )[ querygroup_db ]
Parameters
No parameters for this method
Code
152  protected function update()
153  {
154      $db = querygroup::db();
155      $q  = " UPDATE qi_querygroup SET ";
156      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
157      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
158      $q .= $db->param_string("header") . " = " . $db->value_string($this->_header) . ", ";
159      $q .= $db->param_string("footer") . " = " . $db->value_string($this->_footer) . ", ";
160      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
161      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
162      $q .= " WHERE id = " . $this->_id;
163      $db->query($q);
164      return true;
165  }
 
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[ querygroup_db ]
Code
198  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
199  {
200      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
201      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
202      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
203 
204      $db = querygroup::db();
205      $data = array();
206      $q  = " SELECT $colstring ";
207      $q .= " FROM qi_querygroup ";
208      $q .= " WHERE qi_querygroup.deleted = 0 ";
209      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
210 
211      if (is_string($__order))
212      {
213          $q .= "ORDER BY " . $__order;
214      }
215      else if (is_array($__order) and count($__order)>0)
216      {
217          $orderings = array();
218          foreach ($__order as $col=>$dir)
219          {
220              $orderings[] = " $col $dir ";
221          }
222          $q .= "ORDER BY " . implode(", ", $orderings);
223      }
224      else if (is_object($__order))
225      {
226          $q .= "";
227      }
228      else
229      {
230          // THERE IS NO `order` COLUMN ON THIS OBJECT
231      }
232 
233      if (!is_null($__limit))
234      {
235          $q .= " LIMIT $__offset , $__limit ";
236      }
237 
238      $db->query($q);
239 
240      if (count($colarray)>1 || $colstring=="*")
241      {
242          while ($db->next_record())
243          {
244              $data[] = $db->record;
245          }
246      }
247      else
248      {
249          while ($db->next_record())
250          {
251              $data[] = $db->f(0);
252          }
253      }
254 
255      return $data;
256  }
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[ querygroup_db ]
Code
258  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
259  {
260      return querygroup::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
261  }
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[ querygroup_db ]
Code
263  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
264  {
265      $objects = array();
266      foreach (querygroup::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
267      {
268          $objects[] = new querygroup($id);
269      }
270      return $objects;
271  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicqueryset[ querygroup_db ]
Code
336  public function get_queryset($__type="default")
337  {
338      $object = is_null(keyval($this->property_objects_array,"{$__type}_queryset")) ? new queryset($this->get_queryset_id($__type)) : $this->property_objects_array["{$__type}_queryset"];
339      $this->property_objects_array["{$__type}_queryset"] = $object;
340      return $object;
341  }
Code
373  public function set_queryset($__v, $__type="default")
374  {
375      $object = is_null(keyval($this->property_objects_array,"{$__type}_queryset")) ? new queryset($this->get_queryset_id($__type)) : $this->property_objects_array["{$__type}_queryset"];
376      if (is_null($__v))
377      {
378          $rel = new querygroup_queryset(null,$this->id,$object->id,querygroup_queryset::type_id($__type));
379          $rel->delete();
380          if (!is_null(keyval($this->property_objects_array,"{$__type}_queryset")))
381          {
382              $this->property_objects_array["{$__type}_queryset"] = null;
383          }
384      }
385      else
386      {
387          $id = $object->id;
388          $object = $__v;
389          $object->id = $__v->id>0 ? $__v->id : $id;
390          $object->commit();
391          $this->set_queryset_ids(array($object->id),$__type);
392      }
393  }
publicqueryset_id[ querygroup_db ]
Code
342  public function get_queryset_id($__type="default")
343  {
344      $ids = $this->get_queryset_ids($__type, true);
345      return (count($ids)==1 ? $ids[0] : null);
346  }
Code
394  public function set_queryset_id($__v, $__type="default")
395  {
396      $this->set_queryset_ids(array($__v),$__type);
397  }
publicqueryset_ids[ querygroup_db ]
Code
347  public function get_queryset_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
348  {
349      $queryset_ids = array();
350      $db = querygroup::db();
351      $q  = " SELECT qi_queryset.id FROM qi_querygroup_queryset INNER JOIN qi_queryset ON qi_querygroup_queryset.queryset_id=qi_queryset.id AND qi_querygroup_queryset.deleted=0 AND qi_queryset.deleted=0 AND qi_querygroup_queryset.querygroup_id='$this->id' " . (is_null($__type) ? "" : " AND qi_querygroup_queryset.querygroup_queryset_type_id='" . querygroup_queryset::type_id($__type) . "'") . ($__get_primary ? " AND qi_querygroup_queryset.primary=1 " : "");
352      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
353      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
354      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
355      $db->query($q);
356      while ($db->next_record())
357      {
358          $queryset_ids[] = $db->f("id");
359      }
360      return $queryset_ids;
361  }
Code
398  public function set_queryset_ids($__v, $__type="default")
399  {
400      if ($this->id == 0)
401      {
402          $this->commit();
403      }
404      $type_id = querygroup_queryset::type_id($__type);
405      querygroup_queryset::delete_all($this->id,null,$type_id);
406      $order = 0;
407      if (is_array($__v))
408      {
409          foreach ($__v as $index=>$id)
410          {
411              $object = new querygroup_queryset(null,$this->id,$id,$type_id);
412              $object->deleted = false;
413              $object->order = (++$order);
414              $object->querygroup_queryset_type_id = $type_id;
415              $object->commit();
416              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_queryset")))
417              {
418                  $this->property_objects_array["{$__type}_queryset"] = new queryset($object->queryset_id);
419              }
420          }
421          $this->_dirty = true;
422      }
423  }
publicqueryset_list[ querygroup_db ]
Code
362  public function get_queryset_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
363  {
364      $ids = $this->get_queryset_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
365      $objects = array();
366      foreach ($ids as $index=>$id)
367      {
368          $objects[$index] = new queryset($id);
369      }
370      return $objects;
371  }
Code
424  public function set_queryset_list($__v, $__type="default")
425  {
426      if (is_array($__v))
427      {
428          $ids = array();
429          foreach ($__v as $index=>$object)
430          {
431              $ids[] = $object->id;
432          }
433          $this->set_queryset_ids($ids,$__type);
434      }
435  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads