Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class state extends state_ext

Hide Inherited MembersUser Interface
Description
No description.
 
Constants
constantTABLENAME ["ifc_state"][ state ]
 
Properties
protected_abbreviation[ state_db ]
protected_abbreviation_dirty[ state_db ]
protected_cdate[ state_db ]
protected_cdate_dirty[ state_db ]
protected_deleted[ state_db ]
protected_deleted_dirty[ state_db ]
protected_dirty[ obj ]
protected_id[ state_db ]
protected_id_dirty[ state_db ]
protected_mdate[ state_db ]
protected_mdate_dirty[ state_db ]
protected_name[ state_db ]
protected_name_dirty[ state_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ state_db ]
Parameters
No parameters for this method
Code
100  public function commit()
101  {
102      if ($this->_id > 0)
103      {
104          $this->update();
105      }
106      else
107      {
108          $this->insert();
109      }
110 
111      foreach ($this->property_objects_array as $property=>$object)
112      {
113          $this->{$property} = $object;
114      }
115 
116      return true;
117  }
public__construct ( id , abbreviation )[ state_ext ]
Parameters
optionalid
optionalabbreviation
Code
008  public function __construct($__id=null, $__abbreviation=null)
009  {
010      parent::__construct($__id);
011      if (!is_null($__abbreviation))
012      {
013          $db = state::db();
014          $q  = " SELECT * ";
015          $q .= " FROM " . self::TABLENAME . " ";
016          $q .= " WHERE abbreviation = '$__abbreviation' ";
017          $db->query($q);
018     
019          if ($db->next_record() && $db->num_rows() == 1)
020          {
021              $this->_id = $db->f("id");
022              $this->_name = $db->f("name");
023              $this->_abbreviation = $db->f("abbreviation");
024              $this->_mdate = $db->f("mdate");
025              $this->_cdate = $db->f("cdate");
026              $this->_deleted = $db->f("deleted");
027          }
028      }
029  }
protected staticdb ( )[ state_db ]
Parameters
No parameters for this method
Code
322  protected static function db()
323  {
324      return new db();
325  }
public staticddl_abbrev ( name , value )[ state_ext ]
Parameters
requiredname
optionalvalue
Code
031  static function ddl_abbrev($name, $value=null)
032      {
033          $select = new select($name);
034          $ids = state::get_ids();
035          foreach ($ids as $id) {
036          $o = new state($id);
037              $selected=false;
038          $select->add($o->abbreviation,$o,$selected);
039      }
040      if (!is_null($value))
041      {
042          $select->value = $value;
043      }
044      return $select;
045      }
publicdelete ( )[ state_db ]
Parameters
No parameters for this method
Code
153  public function delete()
154  {
155      $db = state::db();
156      $q  = " UPDATE ifc_state SET ";
157      $q .= " deleted = 1 ";
158      $q .= " WHERE id = " . $this->_id;
159      $db->query($q);
160      $this->deleted = true;
161      return true;
162  }
public staticdelete_all ( )[ state_db ]
Parameters
No parameters for this method
Code
259  public static function delete_all()
260  {
261      $db = state::db();
262      $q  = " UPDATE ifc_state SET ";
263      $q .= " deleted = 1 ";
264     
265      $db->query($q);
266      return true;
267  }
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] )[ state_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
184  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
185  {
186      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
187      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
188      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
189 
190      $db = state::db();
191      $data = array();
192      $q  = " SELECT $colstring ";
193      $q .= " FROM ifc_state ";
194      $q .= " WHERE ifc_state.deleted = 0 ";
195      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
196 
197      if (is_string($__order))
198      {
199          $q .= "ORDER BY " . $__order;
200      }
201      else if (is_array($__order) and count($__order)>0)
202      {
203          $orderings = array();
204          foreach ($__order as $col=>$dir)
205          {
206              $orderings[] = " $col $dir ";
207          }
208          $q .= "ORDER BY " . implode(", ", $orderings);
209      }
210      else if (is_object($__order))
211      {
212          $q .= "";
213      }
214      else
215      {
216          // THERE IS NO `order` COLUMN ON THIS OBJECT
217      }
218 
219      if (!is_null($__limit))
220      {
221          $q .= " LIMIT $__offset , $__limit ";
222      }
223 
224      $db->query($q);
225 
226      if (count($colarray)>1 || $colstring=="*")
227      {
228          while ($db->next_record())
229          {
230              $data[] = $db->record;
231          }
232      }
233      else
234      {
235          while ($db->next_record())
236          {
237              $data[] = $db->f(0);
238          }
239      }
240 
241      return $data;
242  }
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] )[ state_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
244  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
245  {
246      return state::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
247  }
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] )[ state_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
249  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      $objects = array();
252      foreach (state::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
253      {
254          $objects[] = new state($id);
255      }
256      return $objects;
257  }
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 ( )[ state_db ]
Parameters
No parameters for this method
Code
119  protected function insert()
120  {
121      $db = state::db();
122      $q  = " INSERT INTO ifc_state ( ";
123      $q .= $db->param_string("name") . ", ";
124      $q .= $db->param_string("abbreviation") . ", ";
125      $q .= $db->param_string("mdate") . ", ";
126      $q .= $db->param_string("cdate") . ", ";
127      $q .= $db->param_string("deleted");
128      $q .= " ) VALUES ( ";
129      $q .= $db->value_string($this->_name) . ", ";
130      $q .= $db->value_string($this->_abbreviation) . ", ";
131      $q .= $db->value_string(timestamp()) . ", ";
132      $q .= $db->value_string(timestamp()) . ", ";
133      $q .= $this->deleted ? "'1'" : "'0'";
134      $q .= " ) ";
135      $db->query($q);
136      $this->_id = $db->insert_id;
137      return true;
138  }
publicmap ( )[ state_db ]
Parameters
No parameters for this method
Code
091  public function map()
092  {
093      $this->_name = array_key_exists("state:name",$_REQUEST) ? reqval("state:name") : $this->_name;
094      $this->_abbreviation = array_key_exists("state:abbreviation",$_REQUEST) ? reqval("state:abbreviation") : $this->_abbreviation;
095      $this->_mdate = array_key_exists("state:mdate",$_REQUEST) ? reqval("state:mdate") : $this->_mdate;
096      $this->_cdate = array_key_exists("state:cdate",$_REQUEST) ? reqval("state:cdate") : $this->_cdate;
097      $this->_deleted = array_key_exists("state:deleted",$_REQUEST) ? reqval("state:deleted") : $this->_deleted;
098  }
publicpurge ( )[ state_db ]
Parameters
No parameters for this method
Code
175  public function purge()
176  {
177      $db = state::db();
178      $q  = " DELETE FROM ifc_state ";
179      $q .= " WHERE id = " . $this->_id;
180      $db->query($q);
181      return true;
182  }
public staticsearch ( keyword )[ state_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 ( )[ state_db ]
Parameters
No parameters for this method
Code
317  public function __toString()
318  {
319      return (is_null($this->name) ? "" : $this->name);
320  }
publicundelete ( )[ state_db ]
Parameters
No parameters for this method
Code
164  public function undelete()
165  {
166      $db = state::db();
167      $q  = " UPDATE ifc_state SET ";
168      $q .= " deleted = 0 ";
169      $q .= " WHERE id = " . $this->_id;
170      $db->query($q);
171      $this->deleted = false;
172      return true;
173  }
protectedupdate ( )[ state_db ]
Parameters
No parameters for this method
Code
140  protected function update()
141  {
142      $db = state::db();
143      $q  = " UPDATE ifc_state SET ";
144      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
145      $q .= $db->param_string("abbreviation") . " = " . $db->value_string($this->_abbreviation) . ", ";
146      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
147      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
148      $q .= " WHERE id = " . $this->_id;
149      $db->query($q);
150      return true;
151  }
 
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[ state_db ]
Code
184  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
185  {
186      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
187      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
188      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
189 
190      $db = state::db();
191      $data = array();
192      $q  = " SELECT $colstring ";
193      $q .= " FROM ifc_state ";
194      $q .= " WHERE ifc_state.deleted = 0 ";
195      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
196 
197      if (is_string($__order))
198      {
199          $q .= "ORDER BY " . $__order;
200      }
201      else if (is_array($__order) and count($__order)>0)
202      {
203          $orderings = array();
204          foreach ($__order as $col=>$dir)
205          {
206              $orderings[] = " $col $dir ";
207          }
208          $q .= "ORDER BY " . implode(", ", $orderings);
209      }
210      else if (is_object($__order))
211      {
212          $q .= "";
213      }
214      else
215      {
216          // THERE IS NO `order` COLUMN ON THIS OBJECT
217      }
218 
219      if (!is_null($__limit))
220      {
221          $q .= " LIMIT $__offset , $__limit ";
222      }
223 
224      $db->query($q);
225 
226      if (count($colarray)>1 || $colstring=="*")
227      {
228          while ($db->next_record())
229          {
230              $data[] = $db->record;
231          }
232      }
233      else
234      {
235          while ($db->next_record())
236          {
237              $data[] = $db->f(0);
238          }
239      }
240 
241      return $data;
242  }
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[ state_db ]
Code
244  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
245  {
246      return state::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
247  }
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[ state_db ]
Code
249  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      $objects = array();
252      foreach (state::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
253      {
254          $objects[] = new state($id);
255      }
256      return $objects;
257  }
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