Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class country extends country_ext

Hide Inherited MembersUser Interface
Description
No description.
 
Constants
constantTABLENAME ["ifc_country"][ country ]
 
Properties
protected_abbreviation[ country_db ]
protected_abbreviation_3[ country_db ]
protected_abbreviation_3_dirty[ country_db ]
protected_abbreviation_dirty[ country_db ]
protected_cdate[ country_db ]
protected_cdate_dirty[ country_db ]
protected_deleted[ country_db ]
protected_deleted_dirty[ country_db ]
protected_dirty[ obj ]
protected_id[ country_db ]
protected_id_dirty[ country_db ]
protected_mdate[ country_db ]
protected_mdate_dirty[ country_db ]
protected_name[ country_db ]
protected_name_dirty[ country_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ country_db ]
Parameters
No parameters for this method
Code
110  public function commit()
111  {
112      if ($this->_id > 0)
113      {
114          $this->update();
115      }
116      else
117      {
118          $this->insert();
119      }
120 
121      foreach ($this->property_objects_array as $property=>$object)
122      {
123          $this->{$property} = $object;
124      }
125 
126      return true;
127  }
public__construct ( id , abbreviation , abbreviation_3 , name )[ country_ext ]
Parameters
optionalid
optionalabbreviation
optionalabbreviation_3
optionalname
Code
008  public function __construct($__id=null, $__abbreviation=null, $__abbreviation_3=null, $__name=null)
009  {
010      parent::__construct($__id);
011      if (!is_null($__abbreviation))
012      {
013          $db = country::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->_abbreviation_3 = $db->f("abbreviation_3");
025              $this->_mdate = $db->f("mdate");
026              $this->_cdate = $db->f("cdate");
027              $this->_deleted = $db->f("deleted");
028          }
029      }
030      else if (!is_null($__abbreviation_3))
031      {
032          $db = country::db();
033          $q  = " SELECT * ";
034          $q .= " FROM " . self::TABLENAME . " ";
035          $q .= " WHERE `abbreviation_3` = '$__abbreviation_3' ";
036          $db->query($q);
037     
038          if ($db->next_record() && $db->num_rows() == 1)
039          {
040              $this->_id = $db->f("id");
041              $this->_name = $db->f("name");
042              $this->_abbreviation = $db->f("abbreviation");
043              $this->_abbreviation_3 = $db->f("abbreviation_3");
044              $this->_mdate = $db->f("mdate");
045              $this->_cdate = $db->f("cdate");
046              $this->_deleted = $db->f("deleted");
047          }
048      }
049      else if (!is_null($__name))
050      {
051          $db = country::db();
052          $q  = " SELECT * ";
053          $q .= " FROM " . self::TABLENAME . " ";
054          $q .= " WHERE `name` = '$__name' ";
055          $db->query($q);
056     
057          if ($db->next_record() && $db->num_rows() == 1)
058          {
059              $this->_id = $db->f("id");
060              $this->_name = $db->f("name");
061              $this->_abbreviation = $db->f("abbreviation");
062              $this->_abbreviation_3 = $db->f("abbreviation_3");
063              $this->_mdate = $db->f("mdate");
064              $this->_cdate = $db->f("cdate");
065              $this->_deleted = $db->f("deleted");
066          }
067      }
068  }
protected staticdb ( )[ country_db ]
Parameters
No parameters for this method
Code
335  protected static function db()
336  {
337      return new db();
338  }
publicdelete ( )[ country_db ]
Parameters
No parameters for this method
Code
166  public function delete()
167  {
168      $db = country::db();
169      $q  = " UPDATE ifc_country SET ";
170      $q .= " deleted = 1 ";
171      $q .= " WHERE id = " . $this->_id;
172      $db->query($q);
173      $this->deleted = true;
174      return true;
175  }
public staticdelete_all ( )[ country_db ]
Parameters
No parameters for this method
Code
272  public static function delete_all()
273  {
274      $db = country::db();
275      $q  = " UPDATE ifc_country SET ";
276      $q .= " deleted = 1 ";
277     
278      $db->query($q);
279      return true;
280  }
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] )[ country_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
197  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
198  {
199      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
200      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
201      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
202 
203      $db = country::db();
204      $data = array();
205      $q  = " SELECT $colstring ";
206      $q .= " FROM ifc_country ";
207      $q .= " WHERE ifc_country.deleted = 0 ";
208      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
209 
210      if (is_string($__order))
211      {
212          $q .= "ORDER BY " . $__order;
213      }
214      else if (is_array($__order) and count($__order)>0)
215      {
216          $orderings = array();
217          foreach ($__order as $col=>$dir)
218          {
219              $orderings[] = " $col $dir ";
220          }
221          $q .= "ORDER BY " . implode(", ", $orderings);
222      }
223      else if (is_object($__order))
224      {
225          $q .= "";
226      }
227      else
228      {
229          // THERE IS NO `order` COLUMN ON THIS OBJECT
230      }
231 
232      if (!is_null($__limit))
233      {
234          $q .= " LIMIT $__offset , $__limit ";
235      }
236 
237      $db->query($q);
238 
239      if (count($colarray)>1 || $colstring=="*")
240      {
241          while ($db->next_record())
242          {
243              $data[] = $db->record;
244          }
245      }
246      else
247      {
248          while ($db->next_record())
249          {
250              $data[] = $db->f(0);
251          }
252      }
253 
254      return $data;
255  }
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] )[ country_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
257  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
258  {
259      return country::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
260  }
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] )[ country_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
262  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
263  {
264      $objects = array();
265      foreach (country::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
266      {
267          $objects[] = new country($id);
268      }
269      return $objects;
270  }
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 ( )[ country_db ]
Parameters
No parameters for this method
Code
129  protected function insert()
130  {
131      $db = country::db();
132      $q  = " INSERT INTO ifc_country ( ";
133      $q .= $db->param_string("name") . ", ";
134      $q .= $db->param_string("abbreviation") . ", ";
135      $q .= $db->param_string("abbreviation_3") . ", ";
136      $q .= $db->param_string("mdate") . ", ";
137      $q .= $db->param_string("cdate") . ", ";
138      $q .= $db->param_string("deleted");
139      $q .= " ) VALUES ( ";
140      $q .= $db->value_string($this->_name) . ", ";
141      $q .= $db->value_string($this->_abbreviation) . ", ";
142      $q .= $db->value_string($this->_abbreviation_3) . ", ";
143      $q .= $db->value_string(timestamp()) . ", ";
144      $q .= $db->value_string(timestamp()) . ", ";
145      $q .= $this->deleted ? "'1'" : "'0'";
146      $q .= " ) ";
147      $db->query($q);
148      $this->_id = $db->insert_id;
149      return true;
150  }
publicmap ( )[ country_db ]
Parameters
No parameters for this method
Code
100  public function map()
101  {
102      $this->_name = array_key_exists("country:name",$_REQUEST) ? reqval("country:name") : $this->_name;
103      $this->_abbreviation = array_key_exists("country:abbreviation",$_REQUEST) ? reqval("country:abbreviation") : $this->_abbreviation;
104      $this->_abbreviation_3 = array_key_exists("country:abbreviation_3",$_REQUEST) ? reqval("country:abbreviation_3") : $this->_abbreviation_3;
105      $this->_mdate = array_key_exists("country:mdate",$_REQUEST) ? reqval("country:mdate") : $this->_mdate;
106      $this->_cdate = array_key_exists("country:cdate",$_REQUEST) ? reqval("country:cdate") : $this->_cdate;
107      $this->_deleted = array_key_exists("country:deleted",$_REQUEST) ? reqval("country:deleted") : $this->_deleted;
108  }
publicpurge ( )[ country_db ]
Parameters
No parameters for this method
Code
188  public function purge()
189  {
190      $db = country::db();
191      $q  = " DELETE FROM ifc_country ";
192      $q .= " WHERE id = " . $this->_id;
193      $db->query($q);
194      return true;
195  }
public staticsearch ( keyword )[ country_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 ( )[ country_db ]
Parameters
No parameters for this method
Code
330  public function __toString()
331  {
332      return (is_null($this->name) ? "" : $this->name);
333  }
publicundelete ( )[ country_db ]
Parameters
No parameters for this method
Code
177  public function undelete()
178  {
179      $db = country::db();
180      $q  = " UPDATE ifc_country SET ";
181      $q .= " deleted = 0 ";
182      $q .= " WHERE id = " . $this->_id;
183      $db->query($q);
184      $this->deleted = false;
185      return true;
186  }
protectedupdate ( )[ country_db ]
Parameters
No parameters for this method
Code
152  protected function update()
153  {
154      $db = country::db();
155      $q  = " UPDATE ifc_country SET ";
156      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
157      $q .= $db->param_string("abbreviation") . " = " . $db->value_string($this->_abbreviation) . ", ";
158      $q .= $db->param_string("abbreviation_3") . " = " . $db->value_string($this->_abbreviation_3) . ", ";
159      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
160      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
161      $q .= " WHERE id = " . $this->_id;
162      $db->query($q);
163      return true;
164  }
 
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[ country_db ]
Code
197  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
198  {
199      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
200      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
201      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
202 
203      $db = country::db();
204      $data = array();
205      $q  = " SELECT $colstring ";
206      $q .= " FROM ifc_country ";
207      $q .= " WHERE ifc_country.deleted = 0 ";
208      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
209 
210      if (is_string($__order))
211      {
212          $q .= "ORDER BY " . $__order;
213      }
214      else if (is_array($__order) and count($__order)>0)
215      {
216          $orderings = array();
217          foreach ($__order as $col=>$dir)
218          {
219              $orderings[] = " $col $dir ";
220          }
221          $q .= "ORDER BY " . implode(", ", $orderings);
222      }
223      else if (is_object($__order))
224      {
225          $q .= "";
226      }
227      else
228      {
229          // THERE IS NO `order` COLUMN ON THIS OBJECT
230      }
231 
232      if (!is_null($__limit))
233      {
234          $q .= " LIMIT $__offset , $__limit ";
235      }
236 
237      $db->query($q);
238 
239      if (count($colarray)>1 || $colstring=="*")
240      {
241          while ($db->next_record())
242          {
243              $data[] = $db->record;
244          }
245      }
246      else
247      {
248          while ($db->next_record())
249          {
250              $data[] = $db->f(0);
251          }
252      }
253 
254      return $data;
255  }
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[ country_db ]
Code
257  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
258  {
259      return country::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
260  }
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[ country_db ]
Code
262  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
263  {
264      $objects = array();
265      foreach (country::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
266      {
267          $objects[] = new country($id);
268      }
269      return $objects;
270  }
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