Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class business_comment extends business_comment_ext

Hide Inherited MembersContact Relationship
Description
No description.
 
Constants
constantTABLENAME ["crm_business_comment"][ business_comment ]
 
Properties
protected_business_comment_type_id[ business_comment_db ]
protected_business_comment_type_id_dirty[ business_comment_db ]
protected_business_id[ business_comment_db ]
protected_business_id_dirty[ business_comment_db ]
protected_cdate[ business_comment_db ]
protected_cdate_dirty[ business_comment_db ]
protected_comment_id[ business_comment_db ]
protected_comment_id_dirty[ business_comment_db ]
protected_deleted[ business_comment_db ]
protected_deleted_dirty[ business_comment_db ]
protected_dirty[ obj ]
protected_id[ business_comment_db ]
protected_id_dirty[ business_comment_db ]
protected_mdate[ business_comment_db ]
protected_mdate_dirty[ business_comment_db ]
protected_primary[ business_comment_db ]
protected_primary_dirty[ business_comment_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
108  public function commit()
109  {
110      if ($this->_id > 0)
111      {
112          return $this->update();
113      }
114      else
115      {
116          return $this->insert();
117      }
118  }
public__construct ( id , business_entity_id , comment_id , business_comment_type_id [0] )[ business_comment_db ]
Parameters
optionalid
optionalbusiness_entity_id
optionalcomment_id
optionalbusiness_comment_type_id [0]
Code
046  public function __construct($__id=null, $__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=0)
047  {
048      $this->_id = 0;
049      $this->_business_id = 0;
050      $this->_comment_id = 0;
051      $this->_business_comment_type_id = 0;
052      $this->_primary = false;
053      $this->_mdate = null;
054      $this->_cdate = null;
055      $this->_deleted = false;
056 
057      $this->_id_dirty = false;
058      $this->_business_id_dirty = false;
059      $this->_comment_id_dirty = false;
060      $this->_business_comment_type_id_dirty = false;
061      $this->_primary_dirty = false;
062      $this->_mdate_dirty = false;
063      $this->_cdate_dirty = false;
064      $this->_deleted_dirty = false;
065 
066      if (is_null($__business_entity_id) && is_null($__comment_id) && is_null($__business_comment_type_id) && is_null($__id))
067      {
068          return;
069      }
070 
071      $db = business_comment::db();
072      $q  = " SELECT * ";
073      $q .= " FROM crm_business_comment ";       
074      if (!is_null($__id))
075      {
076          $q .= " WHERE id = '$__id' ";
077      }
078      else if (!is_null($__business_entity_id) && !is_null($__comment_id) && !is_null($__business_comment_type_id))
079      {
080          $this->business_id = $__business_entity_id;
081          $this->comment_id = $__comment_id;
082          $this->business_comment_type_id = $__business_comment_type_id;
083          $q .= " WHERE business_entity_id = '$__business_entity_id' AND comment_id = '$__comment_id' AND business_comment_type_id = '$__business_comment_type_id' ";
084      }
085 
086      $db->query($q);
087      if ($db->next_record() && $db->num_rows() == 1)
088      {
089          $this->_id = $db->f("id");
090          $this->_business_id = $db->f("business_entity_id");
091          $this->_comment_id = $db->f("comment_id");
092          $this->_business_comment_type_id = $db->f("business_comment_type_id");
093          $this->_primary = $db->f("primary");
094          $this->_mdate = $db->f("mdate");
095          $this->_cdate = $db->f("cdate");
096          $this->_deleted = $db->f("deleted");
097      }
098  }
protected staticdb ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
447  protected static function db()
448  {
449      return new db();
450  }
publicdelete ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
160  public function delete()
161  {
162      $db = business_comment::db();
163      $q  = " UPDATE crm_business_comment SET ";
164      $q .= " deleted = 1 ";
165      $q .= " WHERE id = '" . $this->_id . "'";
166      $db->query($q);
167      return true;
168  }
public staticdelete_all ( business_entity_id , comment_id , business_comment_type_id )[ business_comment_db ]
Parameters
optionalbusiness_entity_id
optionalcomment_id
optionalbusiness_comment_type_id
Code
267  public static function delete_all($__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null)
268  {
269      $db = business_comment::db();
270      $q  = " UPDATE crm_business_comment SET ";
271      $q .= " deleted = 1 ";
272 
273      $filters = array();
274      if (!is_null($__business_entity_id))
275      {
276          $filters[] = " business_entity_id = '$__business_entity_id' ";
277      }
278      if (!is_null($__comment_id))
279      {
280          $filters[] = " comment_id = '$__comment_id' ";
281      }
282      if (!is_null($__business_comment_type_id))
283      {
284          $filters[] = " business_comment_type_id = '$__business_comment_type_id' ";
285      }
286 
287      $q .= count($filters)>0 ? " WHERE " . implode(" AND ",$filters) . " AND deleted = 0 " : " WHERE deleted=0 ";
288 
289      $db->query($q);
290      return true;
291  }
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_business ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
310  public function get_business()
311  {
312      return new business($this->business_id);
313  }
publicget_business_comment_type ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
334  public function get_business_comment_type()
335  {
336      return new business_comment_type($this->business_comment_type_id);
337  }
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 , business_entity_id , comment_id , business_comment_type_id , order , limit , offset [0] )[ business_comment_db ]
Parameters
requiredcolumns
optionalbusiness_entity_id
optionalcomment_id
optionalbusiness_comment_type_id
optionalorder
optionallimit
optionaloffset [0]
Code
179  public static function get_columns($__columns, $__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null, $__order=null, $__limit=null, $__offset=0)
180  {
181      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
182      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
183 
184      $db = business_comment::db();
185      $data = array();
186      $q  = " SELECT $colstring ";
187      $q .= " FROM crm_business_comment ";
188 
189      $filters = array();
190      if (!is_null($__business_entity_id))
191      {
192          $filters[] = " business_entity_id = '$__business_entity_id' ";
193      }
194      if (!is_null($__comment_id))
195      {
196          $filters[] = " comment_id = '$__comment_id' ";
197      }
198      if (!is_null($__business_comment_type_id))
199      {
200          $filters[] = " business_comment_type_id = '$__business_comment_type_id' ";
201      }
202 
203      $q .= count($filters)>0 ? " WHERE " . implode(" AND ",$filters) . " AND deleted = 0 " : " WHERE deleted=0 ";
204 
205      if (is_string($__order))
206      {
207          $q .= "ORDER BY " . $__order;
208      }
209      else if (is_array($__order) and count($__order)>0)
210      {
211          $orderings = array();
212          foreach ($__order as $col=>$dir)
213          {
214              $orderings[] = " $col $dir ";
215          }
216          $q .= "ORDER BY " . implode(", ", $orderings);
217      }
218      else if (is_object($__order))
219      {
220          $q .= "";
221      }
222      else
223      {
224          // THERE IS NO `order` COLUMN ON THIS OBJECT
225      }
226 
227      if (!is_null($__limit))
228      {
229          $q .= " LIMIT $__offset , $__limit ";
230      }
231 
232      $db->query($q);
233 
234      if (count($colarray)>1 || $colstring=="*")
235      {
236          while ($db->next_record())
237          {
238              $data[] = $db->record;
239          }
240      }
241      else
242      {
243          while ($db->next_record())
244          {
245              $data[] = $db->f(0);
246          }
247      }
248 
249      return $data;
250  }
publicget_comment ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
322  public function get_comment()
323  {
324      return new comment($this->comment_id);
325  }
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 ( business_entity_id , comment_id , business_comment_type_id , order , limit , offset [0] )[ business_comment_db ]
Parameters
optionalbusiness_entity_id
optionalcomment_id
optionalbusiness_comment_type_id
optionalorder
optionallimit
optionaloffset [0]
Code
252  public static function get_ids($__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null, $__order=null, $__limit=null, $__offset=0)
253  {
254      return business_comment::get_columns("id", $__business_entity_id, $__comment_id, $__business_comment_type_id, $__order, $__limit, $__offset);
255  }
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 ( business_entity_id , comment_id , business_comment_type_id , order , limit , offset [0] )[ business_comment_db ]
Parameters
optionalbusiness_entity_id
optionalcomment_id
optionalbusiness_comment_type_id
optionalorder
optionallimit
optionaloffset [0]
Code
257  public static function get_objects($__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null, $__order=null, $__limit=null, $__offset=0)
258  {
259      $objects = array();
260      foreach (business_comment::get_columns("id", $__business_entity_id, $__comment_id, $__business_comment_type_id, $__order, $__limit, $__offset) as $id)
261      {
262          $objects[] = new business_comment($id);
263      }
264      return $objects;
265  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_resource ( type ["default"] )[ business_comment_db ]
Parameters
optionaltype ["default"]
Code
346  public function get_resource($__type="default")
347  {
348      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
349      $this->property_objects_array["{$__type}_resource"] = $object;
350      return $object;
351  }
publicget_resource_id ( type ["default"] )[ business_comment_db ]
Parameters
optionaltype ["default"]
Code
352  public function get_resource_id($__type="default")
353  {
354      $ids = $this->get_resource_ids($__type, true);
355      return (count($ids)==1 ? $ids[0] : null);
356  }
publicget_resource_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ business_comment_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
357  public function get_resource_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
358  {
359      $resource_ids = array();
360      $db = business_comment::db();
361      $q  = " SELECT cor_resource.id FROM crm_businesscomment_resource INNER JOIN cor_resource ON crm_businesscomment_resource.resource_id=cor_resource.id AND crm_businesscomment_resource.deleted=0 AND cor_resource.deleted=0 AND crm_businesscomment_resource.business_comment_business_entity_id,comment_id,business_comment_type_id='$this->id' " . (is_null($__type) ? "" : " AND crm_businesscomment_resource.businesscomment_resource_type_id='" . businesscomment_resource::type_id($__type) . "'") . ($__get_primary ? " AND crm_businesscomment_resource.primary=1 " : "");
362      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
363      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
364      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
365      $db->query($q);
366      while ($db->next_record())
367      {
368          $resource_ids[] = $db->f("id");
369      }
370      return $resource_ids;
371  }
publicget_resource_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ business_comment_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
372  public function get_resource_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
373  {
374      $ids = $this->get_resource_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
375      $objects = array();
376      foreach ($ids as $index=>$id)
377      {
378          $objects[$index] = new resource($id);
379      }
380      return $objects;
381  }
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_type ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
299  public function get_type()
300  {
301      $type = new business_comment_type($this->_business_comment_type_id);
302      return $type->name;
303  }
protectedinsert ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
120  protected function insert()
121  {
122      $db = business_comment::db();
123      $q  = " INSERT INTO crm_business_comment ( ";
124      $q .= $db->param_string("business_entity_id") . ", ";
125      $q .= $db->param_string("comment_id") . ", ";
126      $q .= $db->param_string("business_comment_type_id") . ", ";
127      $q .= $db->param_string("primary") . ", ";
128      $q .= $db->param_string("mdate") . ", ";
129      $q .= $db->param_string("cdate") . ", ";
130      $q .= $db->param_string("deleted");
131      $q .= " ) VALUES ( ";
132      $q .= $db->value_string($this->_business_id) . ", ";
133      $q .= $db->value_string($this->_comment_id) . ", ";
134      $q .= $db->value_string($this->_business_comment_type_id) . ", ";
135      $q .= ($this->_primary ? "'1'" : "'0'") . ", ";
136      $q .= $db->value_string(timestamp()) . ", ";
137      $q .= $db->value_string(timestamp()) . ", ";
138      $q .= $this->deleted ? "'1'" : "'0'";
139      $q .= " ) ";
140      $db->query($q);
141      $this->_id = $db->insert_id;
142      return true;
143  }
publicmap ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
100  public function map()
101  {
102      $this->_primary = array_key_exists("business_comment:primary",$_REQUEST) ? reqval("business_comment:primary") : $this->_primary;
103      $this->_mdate = array_key_exists("business_comment:mdate",$_REQUEST) ? reqval("business_comment:mdate") : $this->_mdate;
104      $this->_cdate = array_key_exists("business_comment:cdate",$_REQUEST) ? reqval("business_comment:cdate") : $this->_cdate;
105      $this->_deleted = array_key_exists("business_comment:deleted",$_REQUEST) ? reqval("business_comment:deleted") : $this->_deleted;
106  }
publicpurge ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
170  public function purge()
171  {
172      $db = business_comment::db();
173      $q  = " DELETE FROM crm_business_comment ";
174      $q .= " WHERE id = '" . $this->_id . "'";
175      $db->query($q);
176      return true;
177  }
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_business ( v )[ business_comment_db ]
Parameters
requiredv
Code
314  public function set_business($v)
315  {
316      if ($v->id > 0)
317      {
318          $this->business_id = $v->id;
319      }
320  }
publicset_business_comment_type ( v )[ business_comment_db ]
Parameters
requiredv
Code
338  public function set_business_comment_type($v)
339  {
340      if ($v->id > 0)
341      {
342          $this->business_comment_type_id = $v->id;
343      }
344  }
publicset_comment ( v )[ business_comment_db ]
Parameters
requiredv
Code
326  public function set_comment($v)
327  {
328      if ($v->id > 0)
329      {
330          $this->comment_id = $v->id;
331      }
332  }
publicset_resource ( v , type ["default"] )[ business_comment_db ]
Parameters
requiredv
optionaltype ["default"]
Code
383  public function set_resource($__v, $__type="default")
384  {
385      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
386      if (is_null($__v))
387      {
388          $rel = new businesscomment_resource(null,$this->id,$object->id,businesscomment_resource::type_id($__type));
389          $rel->delete();
390          if (!is_null(keyval($this->property_objects_array,"{$__type}_resource")))
391          {
392              $this->property_objects_array["{$__type}_resource"] = null;
393          }
394      }
395      else
396      {
397          $hash = $object->hash;
398          $id = $object->id;
399          $object = $__v;
400          $object->hash = $__v->id>0 ? $__v->hash : $hash;
401          $object->id = $__v->id>0 ? $__v->id : $id;
402          $object->commit();
403          $this->set_resource_ids(array($object->id),$__type);
404      }
405  }
publicset_resource_id ( v , type ["default"] )[ business_comment_db ]
Parameters
requiredv
optionaltype ["default"]
Code
406  public function set_resource_id($__v, $__type="default")
407  {
408      $this->set_resource_ids(array($__v),$__type);
409  }
publicset_resource_ids ( v , type ["default"] )[ business_comment_db ]
Parameters
requiredv
optionaltype ["default"]
Code
410  public function set_resource_ids($__v, $__type="default")
411  {
412      if ($this->id == 0)
413      {
414          $this->commit();
415      }
416      $type_id = businesscomment_resource::type_id($__type);
417      businesscomment_resource::delete_all($this->id,null,$type_id);
418      if (is_array($__v))
419      {
420          foreach ($__v as $index=>$id)
421          {
422              $object = new businesscomment_resource(null,$this->id,$id,$type_id);
423              $object->deleted = false;
424              $object->businesscomment_resource_type_id = $type_id;
425              $object->commit();
426              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_resource")))
427              {
428                  $this->property_objects_array["{$__type}_resource"] = new resource($object->resource_id);
429              }
430          }
431          $this->_dirty = true;
432      }
433  }
publicset_resource_list ( v , type ["default"] )[ business_comment_db ]
Parameters
requiredv
optionaltype ["default"]
Code
434  public function set_resource_list($__v, $__type="default")
435  {
436      if (is_array($__v))
437      {
438          $ids = array();
439          foreach ($__v as $index=>$object)
440          {
441              $ids[] = $object->id;
442          }
443          $this->set_resource_ids($ids,$__type);
444      }
445  }
publicset_type ( v )[ business_comment_db ]
Parameters
requiredv
Code
304  public function set_type($v)
305  {
306      $type = new business_comment_type(null, $v);
307      $this->business_comment_type_id = $type->id;
308  }
public statictype_id ( type_name )[ business_comment_db ]
Parameters
requiredtype_name
Code
293  public static function type_id($__type_name)
294  {
295      $type = new business_comment_type(null, $__type_name);
296      return $type->id;
297  }
protectedupdate ( )[ business_comment_db ]
Parameters
No parameters for this method
Code
145  protected function update()
146  {
147      $db = business_comment::db();
148      $q  = " UPDATE crm_business_comment SET ";
149      $q .= $db->param_string("business_entity_id") . " = " . $db->value_string($this->_business_id) . ", ";
150      $q .= $db->param_string("comment_id") . " = " . $db->value_string($this->_comment_id) . ", ";
151      $q .= $db->param_string("business_comment_type_id") . " = " . $db->value_string($this->_business_comment_type_id) . ", ";
152      $q .= $db->param_string("primary") . " = " . ($this->_primary ? "'1'" : "'0'") . ", ";
153      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
154      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
155      $q .= " WHERE id = " . $this->_id;
156      $db->query($q);
157      return true;
158  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicbusiness[ business_comment_db ]
Code
310  public function get_business()
311  {
312      return new business($this->business_id);
313  }
Code
314  public function set_business($v)
315  {
316      if ($v->id > 0)
317      {
318          $this->business_id = $v->id;
319      }
320  }
publicbusiness_comment_type[ business_comment_db ]
Code
334  public function get_business_comment_type()
335  {
336      return new business_comment_type($this->business_comment_type_id);
337  }
Code
338  public function set_business_comment_type($v)
339  {
340      if ($v->id > 0)
341      {
342          $this->business_comment_type_id = $v->id;
343      }
344  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ business_comment_db ]
Code
179  public static function get_columns($__columns, $__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null, $__order=null, $__limit=null, $__offset=0)
180  {
181      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
182      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
183 
184      $db = business_comment::db();
185      $data = array();
186      $q  = " SELECT $colstring ";
187      $q .= " FROM crm_business_comment ";
188 
189      $filters = array();
190      if (!is_null($__business_entity_id))
191      {
192          $filters[] = " business_entity_id = '$__business_entity_id' ";
193      }
194      if (!is_null($__comment_id))
195      {
196          $filters[] = " comment_id = '$__comment_id' ";
197      }
198      if (!is_null($__business_comment_type_id))
199      {
200          $filters[] = " business_comment_type_id = '$__business_comment_type_id' ";
201      }
202 
203      $q .= count($filters)>0 ? " WHERE " . implode(" AND ",$filters) . " AND deleted = 0 " : " WHERE deleted=0 ";
204 
205      if (is_string($__order))
206      {
207          $q .= "ORDER BY " . $__order;
208      }
209      else if (is_array($__order) and count($__order)>0)
210      {
211          $orderings = array();
212          foreach ($__order as $col=>$dir)
213          {
214              $orderings[] = " $col $dir ";
215          }
216          $q .= "ORDER BY " . implode(", ", $orderings);
217      }
218      else if (is_object($__order))
219      {
220          $q .= "";
221      }
222      else
223      {
224          // THERE IS NO `order` COLUMN ON THIS OBJECT
225      }
226 
227      if (!is_null($__limit))
228      {
229          $q .= " LIMIT $__offset , $__limit ";
230      }
231 
232      $db->query($q);
233 
234      if (count($colarray)>1 || $colstring=="*")
235      {
236          while ($db->next_record())
237          {
238              $data[] = $db->record;
239          }
240      }
241      else
242      {
243          while ($db->next_record())
244          {
245              $data[] = $db->f(0);
246          }
247      }
248 
249      return $data;
250  }
publiccomment[ business_comment_db ]
Code
322  public function get_comment()
323  {
324      return new comment($this->comment_id);
325  }
Code
326  public function set_comment($v)
327  {
328      if ($v->id > 0)
329      {
330          $this->comment_id = $v->id;
331      }
332  }
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[ business_comment_db ]
Code
252  public static function get_ids($__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null, $__order=null, $__limit=null, $__offset=0)
253  {
254      return business_comment::get_columns("id", $__business_entity_id, $__comment_id, $__business_comment_type_id, $__order, $__limit, $__offset);
255  }
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[ business_comment_db ]
Code
257  public static function get_objects($__business_entity_id=null, $__comment_id=null, $__business_comment_type_id=null, $__order=null, $__limit=null, $__offset=0)
258  {
259      $objects = array();
260      foreach (business_comment::get_columns("id", $__business_entity_id, $__comment_id, $__business_comment_type_id, $__order, $__limit, $__offset) as $id)
261      {
262          $objects[] = new business_comment($id);
263      }
264      return $objects;
265  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicresource[ business_comment_db ]
Code
346  public function get_resource($__type="default")
347  {
348      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
349      $this->property_objects_array["{$__type}_resource"] = $object;
350      return $object;
351  }
Code
383  public function set_resource($__v, $__type="default")
384  {
385      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
386      if (is_null($__v))
387      {
388          $rel = new businesscomment_resource(null,$this->id,$object->id,businesscomment_resource::type_id($__type));
389          $rel->delete();
390          if (!is_null(keyval($this->property_objects_array,"{$__type}_resource")))
391          {
392              $this->property_objects_array["{$__type}_resource"] = null;
393          }
394      }
395      else
396      {
397          $hash = $object->hash;
398          $id = $object->id;
399          $object = $__v;
400          $object->hash = $__v->id>0 ? $__v->hash : $hash;
401          $object->id = $__v->id>0 ? $__v->id : $id;
402          $object->commit();
403          $this->set_resource_ids(array($object->id),$__type);
404      }
405  }
publicresource_id[ business_comment_db ]
Code
352  public function get_resource_id($__type="default")
353  {
354      $ids = $this->get_resource_ids($__type, true);
355      return (count($ids)==1 ? $ids[0] : null);
356  }
Code
406  public function set_resource_id($__v, $__type="default")
407  {
408      $this->set_resource_ids(array($__v),$__type);
409  }
publicresource_ids[ business_comment_db ]
Code
357  public function get_resource_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
358  {
359      $resource_ids = array();
360      $db = business_comment::db();
361      $q  = " SELECT cor_resource.id FROM crm_businesscomment_resource INNER JOIN cor_resource ON crm_businesscomment_resource.resource_id=cor_resource.id AND crm_businesscomment_resource.deleted=0 AND cor_resource.deleted=0 AND crm_businesscomment_resource.business_comment_business_entity_id,comment_id,business_comment_type_id='$this->id' " . (is_null($__type) ? "" : " AND crm_businesscomment_resource.businesscomment_resource_type_id='" . businesscomment_resource::type_id($__type) . "'") . ($__get_primary ? " AND crm_businesscomment_resource.primary=1 " : "");
362      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
363      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
364      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
365      $db->query($q);
366      while ($db->next_record())
367      {
368          $resource_ids[] = $db->f("id");
369      }
370      return $resource_ids;
371  }
Code
410  public function set_resource_ids($__v, $__type="default")
411  {
412      if ($this->id == 0)
413      {
414          $this->commit();
415      }
416      $type_id = businesscomment_resource::type_id($__type);
417      businesscomment_resource::delete_all($this->id,null,$type_id);
418      if (is_array($__v))
419      {
420          foreach ($__v as $index=>$id)
421          {
422              $object = new businesscomment_resource(null,$this->id,$id,$type_id);
423              $object->deleted = false;
424              $object->businesscomment_resource_type_id = $type_id;
425              $object->commit();
426              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_resource")))
427              {
428                  $this->property_objects_array["{$__type}_resource"] = new resource($object->resource_id);
429              }
430          }
431          $this->_dirty = true;
432      }
433  }
publicresource_list[ business_comment_db ]
Code
372  public function get_resource_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
373  {
374      $ids = $this->get_resource_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
375      $objects = array();
376      foreach ($ids as $index=>$id)
377      {
378          $objects[$index] = new resource($id);
379      }
380      return $objects;
381  }
Code
434  public function set_resource_list($__v, $__type="default")
435  {
436      if (is_array($__v))
437      {
438          $ids = array();
439          foreach ($__v as $index=>$object)
440          {
441              $ids[] = $object->id;
442          }
443          $this->set_resource_ids($ids,$__type);
444      }
445  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publictype[ business_comment_db ]
Code
299  public function get_type()
300  {
301      $type = new business_comment_type($this->_business_comment_type_id);
302      return $type->name;
303  }
Code
304  public function set_type($v)
305  {
306      $type = new business_comment_type(null, $v);
307      $this->business_comment_type_id = $type->id;
308  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads