Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class config extends config_ext

Hide Inherited MembersHelix Core
Description
No description.
 
Constants
constantTABLENAME ["cor_config"][ config ]
 
Properties
protected_cdate[ config_db ]
protected_cdate_dirty[ config_db ]
protected_deleted[ config_db ]
protected_deleted_dirty[ config_db ]
protected_description[ config_db ]
protected_description_dirty[ config_db ]
protected_dirty[ obj ]
protected_id[ config_db ]
protected_id_dirty[ config_db ]
protected_mdate[ config_db ]
protected_mdate_dirty[ config_db ]
protected_name[ config_db ]
protected_name_dirty[ config_db ]
publicproperty_objects_array[ obj ]
protected_value[ config_db ]
protected_value_dirty[ config_db ]
 
Methods
publiccommit ( )[ config_db ]
Parameters
No parameters for this method
Code
102  public function commit()
103  {
104      if ($this->_id > 0)
105      {
106          $this->update();
107      }
108      else
109      {
110          $this->insert();
111      }
112 
113      foreach ($this->property_objects_array as $property=>$object)
114      {
115          $this->{$property} = $object;
116      }
117 
118      return true;
119  }
public__construct ( id , name )[ config_db ]
Parameters
optionalid
optionalname
Code
044  public function __construct($__id=null, $__name=null)
045  {
046      $this->_id = 0;
047      $this->_name = $__name;
048      $this->_value = "";
049      $this->_description = "";
050      $this->_mdate = null;
051      $this->_cdate = null;
052      $this->_deleted = false;
053 
054      $this->_id_dirty = false;
055      $this->_name_dirty = false;
056      $this->_value_dirty = false;
057      $this->_description_dirty = false;
058      $this->_mdate_dirty = false;
059      $this->_cdate_dirty = false;
060      $this->_deleted_dirty = false;
061 
062      if (is_null($__id) && is_null($__name))
063      {
064          return;
065      }
066 
067      $db = config::db();
068      $q  = " SELECT cor_config.id,cor_config.name,cor_config.value,cor_config.description,cor_config.mdate,cor_config.cdate,cor_config.deleted ";
069      $q .= " FROM cor_config ";       
070      if (!is_null($__id))
071      {
072          $q .= " WHERE id = '$__id' ";
073      }
074      else if (!is_null($__name))
075      {
076          $q .= " WHERE name = '$__name' ";
077      }
078 
079      $db->query($q);
080      if ($db->next_record() && $db->num_rows() == 1)
081      {
082          $this->_id = $db->f("id");
083          $this->_name = $db->f("name");
084          $this->_value = $db->f("value");
085          $this->_description = $db->f("description");
086          $this->_mdate = $db->f("mdate");
087          $this->_cdate = $db->f("cdate");
088          $this->_deleted = $db->f("deleted");
089      }
090  }
protected staticdb ( )[ config_db ]
Parameters
No parameters for this method
Code
327  protected static function db()
328  {
329      return new db();
330  }
publicdelete ( )[ config_db ]
Parameters
No parameters for this method
Code
158  public function delete()
159  {
160      $db = config::db();
161      $q  = " UPDATE cor_config SET ";
162      $q .= " deleted = 1 ";
163      $q .= " WHERE id = " . $this->_id;
164      $db->query($q);
165      $this->deleted = true;
166      return true;
167  }
public staticdelete_all ( )[ config_db ]
Parameters
No parameters for this method
Code
264  public static function delete_all()
265  {
266      $db = config::db();
267      $q  = " UPDATE cor_config SET ";
268      $q .= " deleted = 1 ";
269     
270      $db->query($q);
271      return true;
272  }
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] )[ config_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
189  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
190  {
191      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
192      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
193      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
194 
195      $db = config::db();
196      $data = array();
197      $q  = " SELECT $colstring ";
198      $q .= " FROM cor_config ";
199      $q .= " WHERE cor_config.deleted = 0 ";
200      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
201 
202      if (is_string($__order))
203      {
204          $q .= "ORDER BY " . $__order;
205      }
206      else if (is_array($__order) and count($__order)>0)
207      {
208          $orderings = array();
209          foreach ($__order as $col=>$dir)
210          {
211              $orderings[] = " $col $dir ";
212          }
213          $q .= "ORDER BY " . implode(", ", $orderings);
214      }
215      else if (is_object($__order))
216      {
217          $q .= "";
218      }
219      else
220      {
221          // THERE IS NO `order` COLUMN ON THIS OBJECT
222      }
223 
224      if (!is_null($__limit))
225      {
226          $q .= " LIMIT $__offset , $__limit ";
227      }
228 
229      $db->query($q);
230 
231      if (count($colarray)>1 || $colstring=="*")
232      {
233          while ($db->next_record())
234          {
235              $data[] = $db->record;
236          }
237      }
238      else
239      {
240          while ($db->next_record())
241          {
242              $data[] = $db->f(0);
243          }
244      }
245 
246      return $data;
247  }
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] )[ config_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
249  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      return config::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
252  }
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] )[ config_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
254  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
255  {
256      $objects = array();
257      foreach (config::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
258      {
259          $objects[] = new config($id);
260      }
261      return $objects;
262  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
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 ( )[ config_db ]
Parameters
No parameters for this method
Code
121  protected function insert()
122  {
123      $db = config::db();
124      $q  = " INSERT INTO cor_config ( ";
125      $q .= $db->param_string("name") . ", ";
126      $q .= $db->param_string("value") . ", ";
127      $q .= $db->param_string("description") . ", ";
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->_name) . ", ";
133      $q .= $db->value_string($this->_value) . ", ";
134      $q .= $db->value_string($this->_description) . ", ";
135      $q .= $db->value_string(timestamp()) . ", ";
136      $q .= $db->value_string(timestamp()) . ", ";
137      $q .= $this->deleted ? "'1'" : "'0'";
138      $q .= " ) ";
139      $db->query($q);
140      $this->_id = $db->insert_id;
141      return true;
142  }
publicmap ( )[ config_db ]
Parameters
No parameters for this method
Code
092  public function map()
093  {
094      $this->_name = array_key_exists("config:name",$_REQUEST) ? reqval("config:name") : $this->_name;
095      $this->_value = array_key_exists("config:value",$_REQUEST) ? reqval("config:value") : $this->_value;
096      $this->_description = array_key_exists("config:description",$_REQUEST) ? reqval("config:description") : $this->_description;
097      $this->_mdate = array_key_exists("config:mdate",$_REQUEST) ? reqval("config:mdate") : $this->_mdate;
098      $this->_cdate = array_key_exists("config:cdate",$_REQUEST) ? reqval("config:cdate") : $this->_cdate;
099      $this->_deleted = array_key_exists("config:deleted",$_REQUEST) ? reqval("config:deleted") : $this->_deleted;
100  }
publicpurge ( )[ config_db ]
Parameters
No parameters for this method
Code
180  public function purge()
181  {
182      $db = config::db();
183      $q  = " DELETE FROM cor_config ";
184      $q .= " WHERE id = " . $this->_id;
185      $db->query($q);
186      return true;
187  }
public staticsearch ( keyword )[ config_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  }
public__toString ( )[ config_db ]
Parameters
No parameters for this method
Code
322  public function __toString()
323  {
324      return (is_null($this->name) ? "" : $this->name);
325  }
publicundelete ( )[ config_db ]
Parameters
No parameters for this method
Code
169  public function undelete()
170  {
171      $db = config::db();
172      $q  = " UPDATE cor_config SET ";
173      $q .= " deleted = 0 ";
174      $q .= " WHERE id = " . $this->_id;
175      $db->query($q);
176      $this->deleted = false;
177      return true;
178  }
protectedupdate ( )[ config_db ]
Parameters
No parameters for this method
Code
144  protected function update()
145  {
146      $db = config::db();
147      $q  = " UPDATE cor_config SET ";
148      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
149      $q .= $db->param_string("value") . " = " . $db->value_string($this->_value) . ", ";
150      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
151      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
152      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
153      $q .= " WHERE id = " . $this->_id;
154      $db->query($q);
155      return true;
156  }
 
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[ config_db ]
Code
189  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
190  {
191      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
192      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
193      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
194 
195      $db = config::db();
196      $data = array();
197      $q  = " SELECT $colstring ";
198      $q .= " FROM cor_config ";
199      $q .= " WHERE cor_config.deleted = 0 ";
200      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
201 
202      if (is_string($__order))
203      {
204          $q .= "ORDER BY " . $__order;
205      }
206      else if (is_array($__order) and count($__order)>0)
207      {
208          $orderings = array();
209          foreach ($__order as $col=>$dir)
210          {
211              $orderings[] = " $col $dir ";
212          }
213          $q .= "ORDER BY " . implode(", ", $orderings);
214      }
215      else if (is_object($__order))
216      {
217          $q .= "";
218      }
219      else
220      {
221          // THERE IS NO `order` COLUMN ON THIS OBJECT
222      }
223 
224      if (!is_null($__limit))
225      {
226          $q .= " LIMIT $__offset , $__limit ";
227      }
228 
229      $db->query($q);
230 
231      if (count($colarray)>1 || $colstring=="*")
232      {
233          while ($db->next_record())
234          {
235              $data[] = $db->record;
236          }
237      }
238      else
239      {
240          while ($db->next_record())
241          {
242              $data[] = $db->f(0);
243          }
244      }
245 
246      return $data;
247  }
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[ config_db ]
Code
249  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      return config::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
252  }
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[ config_db ]
Code
254  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
255  {
256      $objects = array();
257      foreach (config::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
258      {
259          $objects[] = new config($id);
260      }
261      return $objects;
262  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
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