Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class queryset extends queryset_ext

Hide Inherited MembersForm Builder
Description
No description.
 
Constants
constantTABLENAME ["qi_queryset"][ queryset ]
 
Properties
protected_cdate[ queryset_db ]
protected_cdate_dirty[ queryset_db ]
protected_deleted[ queryset_db ]
protected_deleted_dirty[ queryset_db ]
protected_description[ queryset_db ]
protected_description_dirty[ queryset_db ]
protected_dirty[ obj ]
protected_id[ queryset_db ]
protected_id_dirty[ queryset_db ]
protected_mdate[ queryset_db ]
protected_mdate_dirty[ queryset_db ]
protected_name[ queryset_db ]
protected_name_dirty[ queryset_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ queryset_db ]
Parameters
No parameters for this method
Code
092  public function commit()
093  {
094      if ($this->_id > 0)
095      {
096          $this->update();
097      }
098      else
099      {
100          $this->insert();
101      }
102 
103      foreach ($this->property_objects_array as $property=>$object)
104      {
105          $this->{$property} = $object;
106      }
107 
108      return true;
109  }
public__construct ( id )[ queryset_db ]
Parameters
optionalid
Code
042  public function __construct($__id=null)
043  {
044      $this->_id = 0;
045      $this->_name = "";
046      $this->_description = "";
047      $this->_mdate = null;
048      $this->_cdate = null;
049      $this->_deleted = false;
050 
051      $this->_id_dirty = false;
052      $this->_name_dirty = false;
053      $this->_description_dirty = false;
054      $this->_mdate_dirty = false;
055      $this->_cdate_dirty = false;
056      $this->_deleted_dirty = false;
057 
058      if (is_null($__id))
059      {
060          return;
061      }
062 
063      $db = queryset::db();
064      $q  = " SELECT qi_queryset.id,qi_queryset.name,qi_queryset.description,qi_queryset.mdate,qi_queryset.cdate,qi_queryset.deleted ";
065      $q .= " FROM qi_queryset ";       
066      if (!is_null($__id))
067      {
068          $q .= " WHERE id = '$__id' ";
069      }
070 
071      $db->query($q);
072      if ($db->next_record() && $db->num_rows() == 1)
073      {
074          $this->_id = $db->f("id");
075          $this->_name = $db->f("name");
076          $this->_description = $db->f("description");
077          $this->_mdate = $db->f("mdate");
078          $this->_cdate = $db->f("cdate");
079          $this->_deleted = $db->f("deleted");
080      }
081  }
protected staticdb ( )[ queryset_db ]
Parameters
No parameters for this method
Code
615  protected static function db()
616  {
617      return new db();
618  }
publicdelete ( )[ queryset_db ]
Parameters
No parameters for this method
Code
145  public function delete()
146  {
147      $db = queryset::db();
148      $q  = " UPDATE qi_queryset SET ";
149      $q .= " deleted = 1 ";
150      $q .= " WHERE id = " . $this->_id;
151      $db->query($q);
152      $this->deleted = true;
153      return true;
154  }
public staticdelete_all ( )[ queryset_db ]
Parameters
No parameters for this method
Code
251  public static function delete_all()
252  {
253      $db = queryset::db();
254      $q  = " UPDATE qi_queryset SET ";
255      $q .= " deleted = 1 ";
256     
257      $db->query($q);
258      return true;
259  }
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] )[ queryset_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
176  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
177  {
178      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
179      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
180      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
181 
182      $db = queryset::db();
183      $data = array();
184      $q  = " SELECT $colstring ";
185      $q .= " FROM qi_queryset ";
186      $q .= " WHERE qi_queryset.deleted = 0 ";
187      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
188 
189      if (is_string($__order))
190      {
191          $q .= "ORDER BY " . $__order;
192      }
193      else if (is_array($__order) and count($__order)>0)
194      {
195          $orderings = array();
196          foreach ($__order as $col=>$dir)
197          {
198              $orderings[] = " $col $dir ";
199          }
200          $q .= "ORDER BY " . implode(", ", $orderings);
201      }
202      else if (is_object($__order))
203      {
204          $q .= "";
205      }
206      else
207      {
208          // THERE IS NO `order` COLUMN ON THIS OBJECT
209      }
210 
211      if (!is_null($__limit))
212      {
213          $q .= " LIMIT $__offset , $__limit ";
214      }
215 
216      $db->query($q);
217 
218      if (count($colarray)>1 || $colstring=="*")
219      {
220          while ($db->next_record())
221          {
222              $data[] = $db->record;
223          }
224      }
225      else
226      {
227          while ($db->next_record())
228          {
229              $data[] = $db->f(0);
230          }
231      }
232 
233      return $data;
234  }
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] )[ queryset_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
236  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
237  {
238      return queryset::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
239  }
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] )[ queryset_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
241  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
242  {
243      $objects = array();
244      foreach (queryset::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
245      {
246          $objects[] = new queryset($id);
247      }
248      return $objects;
249  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_query ( type ["default"] )[ queryset_db ]
Parameters
optionaltype ["default"]
Code
314  public function get_query($__type="default")
315  {
316      $object = is_null(keyval($this->property_objects_array,"{$__type}_query")) ? new query($this->get_query_id($__type)) : $this->property_objects_array["{$__type}_query"];
317      $this->property_objects_array["{$__type}_query"] = $object;
318      return $object;
319  }
publicget_query_id ( type ["default"] )[ queryset_db ]
Parameters
optionaltype ["default"]
Code
320  public function get_query_id($__type="default")
321  {
322      $ids = $this->get_query_ids($__type, true);
323      return (count($ids)==1 ? $ids[0] : null);
324  }
publicget_query_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ queryset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
325  public function get_query_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
326  {
327      $query_ids = array();
328      $db = queryset::db();
329      $q  = " SELECT qi_query.id FROM qi_query_queryset INNER JOIN qi_query ON qi_query_queryset.query_id=qi_query.id AND qi_query_queryset.deleted=0 AND qi_query.deleted=0 AND qi_query_queryset.queryset_id='$this->id' " . (is_null($__type) ? "" : " AND qi_query_queryset.query_queryset_type_id='" . query_queryset::type_id($__type) . "'") . ($__get_primary ? " AND qi_query_queryset.primary=1 " : "");
330      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
331      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
332      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
333      $db->query($q);
334      while ($db->next_record())
335      {
336          $query_ids[] = $db->f("id");
337      }
338      return $query_ids;
339  }
publicget_query_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ queryset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
340  public function get_query_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
341  {
342      $ids = $this->get_query_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
343      $objects = array();
344      foreach ($ids as $index=>$id)
345      {
346          $objects[$index] = new query($id);
347      }
348      return $objects;
349  }
publicget_querygroup ( type ["default"] )[ queryset_db ]
Parameters
optionaltype ["default"]
Code
415  public function get_querygroup($__type="default")
416  {
417      $object = is_null(keyval($this->property_objects_array,"{$__type}_querygroup")) ? new querygroup($this->get_querygroup_id($__type)) : $this->property_objects_array["{$__type}_querygroup"];
418      $this->property_objects_array["{$__type}_querygroup"] = $object;
419      return $object;
420  }
publicget_querygroup_id ( type ["default"] )[ queryset_db ]
Parameters
optionaltype ["default"]
Code
421  public function get_querygroup_id($__type="default")
422  {
423      $ids = $this->get_querygroup_ids($__type, true);
424      return (count($ids)==1 ? $ids[0] : null);
425  }
publicget_querygroup_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ queryset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
426  public function get_querygroup_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
427  {
428      $querygroup_ids = array();
429      $db = queryset::db();
430      $q  = " SELECT qi_querygroup.id FROM qi_querygroup_queryset INNER JOIN qi_querygroup ON qi_querygroup_queryset.querygroup_id=qi_querygroup.id AND qi_querygroup_queryset.deleted=0 AND qi_querygroup.deleted=0 AND qi_querygroup_queryset.queryset_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 " : "");
431      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
432      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
433      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
434      $db->query($q);
435      while ($db->next_record())
436      {
437          $querygroup_ids[] = $db->f("id");
438      }
439      return $querygroup_ids;
440  }
publicget_querygroup_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ queryset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
441  public function get_querygroup_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
442  {
443      $ids = $this->get_querygroup_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
444      $objects = array();
445      foreach ($ids as $index=>$id)
446      {
447          $objects[$index] = new querygroup($id);
448      }
449      return $objects;
450  }
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_user ( type ["default"] )[ queryset_db ]
Parameters
optionaltype ["default"]
Code
516  public function get_user($__type="default")
517  {
518      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
519      $this->property_objects_array["{$__type}_user"] = $object;
520      return $object;
521  }
publicget_user_id ( type ["default"] )[ queryset_db ]
Parameters
optionaltype ["default"]
Code
522  public function get_user_id($__type="default")
523  {
524      $ids = $this->get_user_ids($__type, true);
525      return (count($ids)==1 ? $ids[0] : null);
526  }
publicget_user_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ queryset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
527  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
528  {
529      $user_ids = array();
530      $db = queryset::db();
531      $q  = " SELECT cor_user.person_entity_id FROM qi_queryset_user INNER JOIN cor_user ON qi_queryset_user.user_person_entity_id=cor_user.person_entity_id AND qi_queryset_user.deleted=0 AND cor_user.deleted=0 AND qi_queryset_user.queryset_id='$this->id' " . (is_null($__type) ? "" : " AND qi_queryset_user.queryset_user_type_id='" . queryset_user::type_id($__type) . "'") . ($__get_primary ? " AND qi_queryset_user.primary=1 " : "");
532      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
533      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
534      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
535      $db->query($q);
536      while ($db->next_record())
537      {
538          $user_ids[] = $db->f("person_entity_id");
539      }
540      return $user_ids;
541  }
publicget_user_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ queryset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
542  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
543  {
544      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
545      $objects = array();
546      foreach ($ids as $index=>$id)
547      {
548          $objects[$index] = new user($id);
549      }
550      return $objects;
551  }
protectedinsert ( )[ queryset_db ]
Parameters
No parameters for this method
Code
111  protected function insert()
112  {
113      $db = queryset::db();
114      $q  = " INSERT INTO qi_queryset ( ";
115      $q .= $db->param_string("name") . ", ";
116      $q .= $db->param_string("description") . ", ";
117      $q .= $db->param_string("mdate") . ", ";
118      $q .= $db->param_string("cdate") . ", ";
119      $q .= $db->param_string("deleted");
120      $q .= " ) VALUES ( ";
121      $q .= $db->value_string($this->_name) . ", ";
122      $q .= $db->value_string($this->_description) . ", ";
123      $q .= $db->value_string(timestamp()) . ", ";
124      $q .= $db->value_string(timestamp()) . ", ";
125      $q .= $this->deleted ? "'1'" : "'0'";
126      $q .= " ) ";
127      $db->query($q);
128      $this->_id = $db->insert_id;
129      return true;
130  }
publicmap ( )[ queryset_db ]
Parameters
No parameters for this method
Code
083  public function map()
084  {
085      $this->_name = array_key_exists("queryset:name",$_REQUEST) ? reqval("queryset:name") : $this->_name;
086      $this->_description = array_key_exists("queryset:description",$_REQUEST) ? reqval("queryset:description") : $this->_description;
087      $this->_mdate = array_key_exists("queryset:mdate",$_REQUEST) ? reqval("queryset:mdate") : $this->_mdate;
088      $this->_cdate = array_key_exists("queryset:cdate",$_REQUEST) ? reqval("queryset:cdate") : $this->_cdate;
089      $this->_deleted = array_key_exists("queryset:deleted",$_REQUEST) ? reqval("queryset:deleted") : $this->_deleted;
090  }
publicpurge ( )[ queryset_db ]
Parameters
No parameters for this method
Code
167  public function purge()
168  {
169      $db = queryset::db();
170      $q  = " DELETE FROM qi_queryset ";
171      $q .= " WHERE id = " . $this->_id;
172      $db->query($q);
173      return true;
174  }
public staticsearch ( keyword )[ queryset_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_query ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
351  public function set_query($__v, $__type="default")
352  {
353      $object = is_null(keyval($this->property_objects_array,"{$__type}_query")) ? new query($this->get_query_id($__type)) : $this->property_objects_array["{$__type}_query"];
354      if (is_null($__v))
355      {
356          $rel = new query_queryset(null,$object->id,$this->id,query_queryset::type_id($__type));
357          $rel->delete();
358          if (!is_null(keyval($this->property_objects_array,"{$__type}_query")))
359          {
360              $this->property_objects_array["{$__type}_query"] = null;
361          }
362      }
363      else
364      {
365          $id = $object->id;
366          $object = $__v;
367          $object->id = $__v->id>0 ? $__v->id : $id;
368          $object->commit();
369          $this->set_query_ids(array($object->id),$__type);
370      }
371  }
publicset_query_id ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
372  public function set_query_id($__v, $__type="default")
373  {
374      $this->set_query_ids(array($__v),$__type);
375  }
publicset_query_ids ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
376  public function set_query_ids($__v, $__type="default")
377  {
378      if ($this->id == 0)
379      {
380          $this->commit();
381      }
382      $type_id = query_queryset::type_id($__type);
383      query_queryset::delete_all(null,$this->id,$type_id);
384      $order = 0;
385      if (is_array($__v))
386      {
387          foreach ($__v as $index=>$id)
388          {
389              $object = new query_queryset(null,$id,$this->id,$type_id);
390              $object->deleted = false;
391              $object->order = (++$order);
392              $object->query_queryset_type_id = $type_id;
393              $object->commit();
394              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_query")))
395              {
396                  $this->property_objects_array["{$__type}_query"] = new query($object->query_id);
397              }
398          }
399          $this->_dirty = true;
400      }
401  }
publicset_query_list ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
402  public function set_query_list($__v, $__type="default")
403  {
404      if (is_array($__v))
405      {
406          $ids = array();
407          foreach ($__v as $index=>$object)
408          {
409              $ids[] = $object->id;
410          }
411          $this->set_query_ids($ids,$__type);
412      }
413  }
publicset_querygroup ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
452  public function set_querygroup($__v, $__type="default")
453  {
454      $object = is_null(keyval($this->property_objects_array,"{$__type}_querygroup")) ? new querygroup($this->get_querygroup_id($__type)) : $this->property_objects_array["{$__type}_querygroup"];
455      if (is_null($__v))
456      {
457          $rel = new querygroup_queryset(null,$object->id,$this->id,querygroup_queryset::type_id($__type));
458          $rel->delete();
459          if (!is_null(keyval($this->property_objects_array,"{$__type}_querygroup")))
460          {
461              $this->property_objects_array["{$__type}_querygroup"] = null;
462          }
463      }
464      else
465      {
466          $id = $object->id;
467          $object = $__v;
468          $object->id = $__v->id>0 ? $__v->id : $id;
469          $object->commit();
470          $this->set_querygroup_ids(array($object->id),$__type);
471      }
472  }
publicset_querygroup_id ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
473  public function set_querygroup_id($__v, $__type="default")
474  {
475      $this->set_querygroup_ids(array($__v),$__type);
476  }
publicset_querygroup_ids ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
477  public function set_querygroup_ids($__v, $__type="default")
478  {
479      if ($this->id == 0)
480      {
481          $this->commit();
482      }
483      $type_id = querygroup_queryset::type_id($__type);
484      querygroup_queryset::delete_all(null,$this->id,$type_id);
485      $order = 0;
486      if (is_array($__v))
487      {
488          foreach ($__v as $index=>$id)
489          {
490              $object = new querygroup_queryset(null,$id,$this->id,$type_id);
491              $object->deleted = false;
492              $object->order = (++$order);
493              $object->querygroup_queryset_type_id = $type_id;
494              $object->commit();
495              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_querygroup")))
496              {
497                  $this->property_objects_array["{$__type}_querygroup"] = new querygroup($object->querygroup_id);
498              }
499          }
500          $this->_dirty = true;
501      }
502  }
publicset_querygroup_list ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
503  public function set_querygroup_list($__v, $__type="default")
504  {
505      if (is_array($__v))
506      {
507          $ids = array();
508          foreach ($__v as $index=>$object)
509          {
510              $ids[] = $object->id;
511          }
512          $this->set_querygroup_ids($ids,$__type);
513      }
514  }
publicset_user ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
553  public function set_user($__v, $__type="default")
554  {
555      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
556      if (is_null($__v))
557      {
558          $rel = new queryset_user(null,$this->id,$object->id,queryset_user::type_id($__type));
559          $rel->delete();
560          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
561          {
562              $this->property_objects_array["{$__type}_user"] = null;
563          }
564      }
565      else
566      {
567          $id = $object->id;
568          $object = $__v;
569          $object->id = $__v->id>0 ? $__v->id : $id;
570          $object->commit();
571          $this->set_user_ids(array($object->id),$__type);
572      }
573  }
publicset_user_id ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
574  public function set_user_id($__v, $__type="default")
575  {
576      $this->set_user_ids(array($__v),$__type);
577  }
publicset_user_ids ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
578  public function set_user_ids($__v, $__type="default")
579  {
580      if ($this->id == 0)
581      {
582          $this->commit();
583      }
584      $type_id = queryset_user::type_id($__type);
585      queryset_user::delete_all($this->id,null,$type_id);
586      if (is_array($__v))
587      {
588          foreach ($__v as $index=>$id)
589          {
590              $object = new queryset_user(null,$this->id,$id,$type_id);
591              $object->deleted = false;
592              $object->queryset_user_type_id = $type_id;
593              $object->commit();
594              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
595              {
596                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
597              }
598          }
599          $this->_dirty = true;
600      }
601  }
publicset_user_list ( v , type ["default"] )[ queryset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
602  public function set_user_list($__v, $__type="default")
603  {
604      if (is_array($__v))
605      {
606          $ids = array();
607          foreach ($__v as $index=>$object)
608          {
609              $ids[] = $object->id;
610          }
611          $this->set_user_ids($ids,$__type);
612      }
613  }
public__toString ( )[ queryset_db ]
Parameters
No parameters for this method
Code
309  public function __toString()
310  {
311      return (is_null($this->name) ? "" : $this->name);
312  }
publicundelete ( )[ queryset_db ]
Parameters
No parameters for this method
Code
156  public function undelete()
157  {
158      $db = queryset::db();
159      $q  = " UPDATE qi_queryset SET ";
160      $q .= " deleted = 0 ";
161      $q .= " WHERE id = " . $this->_id;
162      $db->query($q);
163      $this->deleted = false;
164      return true;
165  }
protectedupdate ( )[ queryset_db ]
Parameters
No parameters for this method
Code
132  protected function update()
133  {
134      $db = queryset::db();
135      $q  = " UPDATE qi_queryset SET ";
136      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
137      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
138      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
139      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
140      $q .= " WHERE id = " . $this->_id;
141      $db->query($q);
142      return true;
143  }
 
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[ queryset_db ]
Code
176  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
177  {
178      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
179      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
180      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
181 
182      $db = queryset::db();
183      $data = array();
184      $q  = " SELECT $colstring ";
185      $q .= " FROM qi_queryset ";
186      $q .= " WHERE qi_queryset.deleted = 0 ";
187      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
188 
189      if (is_string($__order))
190      {
191          $q .= "ORDER BY " . $__order;
192      }
193      else if (is_array($__order) and count($__order)>0)
194      {
195          $orderings = array();
196          foreach ($__order as $col=>$dir)
197          {
198              $orderings[] = " $col $dir ";
199          }
200          $q .= "ORDER BY " . implode(", ", $orderings);
201      }
202      else if (is_object($__order))
203      {
204          $q .= "";
205      }
206      else
207      {
208          // THERE IS NO `order` COLUMN ON THIS OBJECT
209      }
210 
211      if (!is_null($__limit))
212      {
213          $q .= " LIMIT $__offset , $__limit ";
214      }
215 
216      $db->query($q);
217 
218      if (count($colarray)>1 || $colstring=="*")
219      {
220          while ($db->next_record())
221          {
222              $data[] = $db->record;
223          }
224      }
225      else
226      {
227          while ($db->next_record())
228          {
229              $data[] = $db->f(0);
230          }
231      }
232 
233      return $data;
234  }
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[ queryset_db ]
Code
236  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
237  {
238      return queryset::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
239  }
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[ queryset_db ]
Code
241  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
242  {
243      $objects = array();
244      foreach (queryset::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
245      {
246          $objects[] = new queryset($id);
247      }
248      return $objects;
249  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicquery[ queryset_db ]
Code
314  public function get_query($__type="default")
315  {
316      $object = is_null(keyval($this->property_objects_array,"{$__type}_query")) ? new query($this->get_query_id($__type)) : $this->property_objects_array["{$__type}_query"];
317      $this->property_objects_array["{$__type}_query"] = $object;
318      return $object;
319  }
Code
351  public function set_query($__v, $__type="default")
352  {
353      $object = is_null(keyval($this->property_objects_array,"{$__type}_query")) ? new query($this->get_query_id($__type)) : $this->property_objects_array["{$__type}_query"];
354      if (is_null($__v))
355      {
356          $rel = new query_queryset(null,$object->id,$this->id,query_queryset::type_id($__type));
357          $rel->delete();
358          if (!is_null(keyval($this->property_objects_array,"{$__type}_query")))
359          {
360              $this->property_objects_array["{$__type}_query"] = null;
361          }
362      }
363      else
364      {
365          $id = $object->id;
366          $object = $__v;
367          $object->id = $__v->id>0 ? $__v->id : $id;
368          $object->commit();
369          $this->set_query_ids(array($object->id),$__type);
370      }
371  }
publicquery_id[ queryset_db ]
Code
320  public function get_query_id($__type="default")
321  {
322      $ids = $this->get_query_ids($__type, true);
323      return (count($ids)==1 ? $ids[0] : null);
324  }
Code
372  public function set_query_id($__v, $__type="default")
373  {
374      $this->set_query_ids(array($__v),$__type);
375  }
publicquery_ids[ queryset_db ]
Code
325  public function get_query_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
326  {
327      $query_ids = array();
328      $db = queryset::db();
329      $q  = " SELECT qi_query.id FROM qi_query_queryset INNER JOIN qi_query ON qi_query_queryset.query_id=qi_query.id AND qi_query_queryset.deleted=0 AND qi_query.deleted=0 AND qi_query_queryset.queryset_id='$this->id' " . (is_null($__type) ? "" : " AND qi_query_queryset.query_queryset_type_id='" . query_queryset::type_id($__type) . "'") . ($__get_primary ? " AND qi_query_queryset.primary=1 " : "");
330      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
331      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
332      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
333      $db->query($q);
334      while ($db->next_record())
335      {
336          $query_ids[] = $db->f("id");
337      }
338      return $query_ids;
339  }
Code
376  public function set_query_ids($__v, $__type="default")
377  {
378      if ($this->id == 0)
379      {
380          $this->commit();
381      }
382      $type_id = query_queryset::type_id($__type);
383      query_queryset::delete_all(null,$this->id,$type_id);
384      $order = 0;
385      if (is_array($__v))
386      {
387          foreach ($__v as $index=>$id)
388          {
389              $object = new query_queryset(null,$id,$this->id,$type_id);
390              $object->deleted = false;
391              $object->order = (++$order);
392              $object->query_queryset_type_id = $type_id;
393              $object->commit();
394              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_query")))
395              {
396                  $this->property_objects_array["{$__type}_query"] = new query($object->query_id);
397              }
398          }
399          $this->_dirty = true;
400      }
401  }
publicquery_list[ queryset_db ]
Code
340  public function get_query_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
341  {
342      $ids = $this->get_query_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
343      $objects = array();
344      foreach ($ids as $index=>$id)
345      {
346          $objects[$index] = new query($id);
347      }
348      return $objects;
349  }
Code
402  public function set_query_list($__v, $__type="default")
403  {
404      if (is_array($__v))
405      {
406          $ids = array();
407          foreach ($__v as $index=>$object)
408          {
409              $ids[] = $object->id;
410          }
411          $this->set_query_ids($ids,$__type);
412      }
413  }
publicquerygroup[ queryset_db ]
Code
415  public function get_querygroup($__type="default")
416  {
417      $object = is_null(keyval($this->property_objects_array,"{$__type}_querygroup")) ? new querygroup($this->get_querygroup_id($__type)) : $this->property_objects_array["{$__type}_querygroup"];
418      $this->property_objects_array["{$__type}_querygroup"] = $object;
419      return $object;
420  }
Code
452  public function set_querygroup($__v, $__type="default")
453  {
454      $object = is_null(keyval($this->property_objects_array,"{$__type}_querygroup")) ? new querygroup($this->get_querygroup_id($__type)) : $this->property_objects_array["{$__type}_querygroup"];
455      if (is_null($__v))
456      {
457          $rel = new querygroup_queryset(null,$object->id,$this->id,querygroup_queryset::type_id($__type));
458          $rel->delete();
459          if (!is_null(keyval($this->property_objects_array,"{$__type}_querygroup")))
460          {
461              $this->property_objects_array["{$__type}_querygroup"] = null;
462          }
463      }
464      else
465      {
466          $id = $object->id;
467          $object = $__v;
468          $object->id = $__v->id>0 ? $__v->id : $id;
469          $object->commit();
470          $this->set_querygroup_ids(array($object->id),$__type);
471      }
472  }
publicquerygroup_id[ queryset_db ]
Code
421  public function get_querygroup_id($__type="default")
422  {
423      $ids = $this->get_querygroup_ids($__type, true);
424      return (count($ids)==1 ? $ids[0] : null);
425  }
Code
473  public function set_querygroup_id($__v, $__type="default")
474  {
475      $this->set_querygroup_ids(array($__v),$__type);
476  }
publicquerygroup_ids[ queryset_db ]
Code
426  public function get_querygroup_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
427  {
428      $querygroup_ids = array();
429      $db = queryset::db();
430      $q  = " SELECT qi_querygroup.id FROM qi_querygroup_queryset INNER JOIN qi_querygroup ON qi_querygroup_queryset.querygroup_id=qi_querygroup.id AND qi_querygroup_queryset.deleted=0 AND qi_querygroup.deleted=0 AND qi_querygroup_queryset.queryset_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 " : "");
431      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
432      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
433      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
434      $db->query($q);
435      while ($db->next_record())
436      {
437          $querygroup_ids[] = $db->f("id");
438      }
439      return $querygroup_ids;
440  }
Code
477  public function set_querygroup_ids($__v, $__type="default")
478  {
479      if ($this->id == 0)
480      {
481          $this->commit();
482      }
483      $type_id = querygroup_queryset::type_id($__type);
484      querygroup_queryset::delete_all(null,$this->id,$type_id);
485      $order = 0;
486      if (is_array($__v))
487      {
488          foreach ($__v as $index=>$id)
489          {
490              $object = new querygroup_queryset(null,$id,$this->id,$type_id);
491              $object->deleted = false;
492              $object->order = (++$order);
493              $object->querygroup_queryset_type_id = $type_id;
494              $object->commit();
495              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_querygroup")))
496              {
497                  $this->property_objects_array["{$__type}_querygroup"] = new querygroup($object->querygroup_id);
498              }
499          }
500          $this->_dirty = true;
501      }
502  }
publicquerygroup_list[ queryset_db ]
Code
441  public function get_querygroup_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
442  {
443      $ids = $this->get_querygroup_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
444      $objects = array();
445      foreach ($ids as $index=>$id)
446      {
447          $objects[$index] = new querygroup($id);
448      }
449      return $objects;
450  }
Code
503  public function set_querygroup_list($__v, $__type="default")
504  {
505      if (is_array($__v))
506      {
507          $ids = array();
508          foreach ($__v as $index=>$object)
509          {
510              $ids[] = $object->id;
511          }
512          $this->set_querygroup_ids($ids,$__type);
513      }
514  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicuser[ queryset_db ]
Code
516  public function get_user($__type="default")
517  {
518      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
519      $this->property_objects_array["{$__type}_user"] = $object;
520      return $object;
521  }
Code
553  public function set_user($__v, $__type="default")
554  {
555      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
556      if (is_null($__v))
557      {
558          $rel = new queryset_user(null,$this->id,$object->id,queryset_user::type_id($__type));
559          $rel->delete();
560          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
561          {
562              $this->property_objects_array["{$__type}_user"] = null;
563          }
564      }
565      else
566      {
567          $id = $object->id;
568          $object = $__v;
569          $object->id = $__v->id>0 ? $__v->id : $id;
570          $object->commit();
571          $this->set_user_ids(array($object->id),$__type);
572      }
573  }
publicuser_id[ queryset_db ]
Code
522  public function get_user_id($__type="default")
523  {
524      $ids = $this->get_user_ids($__type, true);
525      return (count($ids)==1 ? $ids[0] : null);
526  }
Code
574  public function set_user_id($__v, $__type="default")
575  {
576      $this->set_user_ids(array($__v),$__type);
577  }
publicuser_ids[ queryset_db ]
Code
527  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
528  {
529      $user_ids = array();
530      $db = queryset::db();
531      $q  = " SELECT cor_user.person_entity_id FROM qi_queryset_user INNER JOIN cor_user ON qi_queryset_user.user_person_entity_id=cor_user.person_entity_id AND qi_queryset_user.deleted=0 AND cor_user.deleted=0 AND qi_queryset_user.queryset_id='$this->id' " . (is_null($__type) ? "" : " AND qi_queryset_user.queryset_user_type_id='" . queryset_user::type_id($__type) . "'") . ($__get_primary ? " AND qi_queryset_user.primary=1 " : "");
532      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
533      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
534      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
535      $db->query($q);
536      while ($db->next_record())
537      {
538          $user_ids[] = $db->f("person_entity_id");
539      }
540      return $user_ids;
541  }
Code
578  public function set_user_ids($__v, $__type="default")
579  {
580      if ($this->id == 0)
581      {
582          $this->commit();
583      }
584      $type_id = queryset_user::type_id($__type);
585      queryset_user::delete_all($this->id,null,$type_id);
586      if (is_array($__v))
587      {
588          foreach ($__v as $index=>$id)
589          {
590              $object = new queryset_user(null,$this->id,$id,$type_id);
591              $object->deleted = false;
592              $object->queryset_user_type_id = $type_id;
593              $object->commit();
594              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
595              {
596                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
597              }
598          }
599          $this->_dirty = true;
600      }
601  }
publicuser_list[ queryset_db ]
Code
542  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
543  {
544      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
545      $objects = array();
546      foreach ($ids as $index=>$id)
547      {
548          $objects[$index] = new user($id);
549      }
550      return $objects;
551  }
Code
602  public function set_user_list($__v, $__type="default")
603  {
604      if (is_array($__v))
605      {
606          $ids = array();
607          foreach ($__v as $index=>$object)
608          {
609              $ids[] = $object->id;
610          }
611          $this->set_user_ids($ids,$__type);
612      }
613  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads