Go to the documentation of this file.00001 <?php
00010 class db_whereClause extends object {
00011
00015 public function __set($name, $val) {
00016 $this->cfg->set($name, $val);
00017 }
00018
00022 public function between($st, $end) {
00023 $this->cfg->mt = $st;
00024 $this->cfg->lt = $end;
00025 }
00026
00030 public function betweenEq($st, $end) {
00031 $this->cfg->mte = $st;
00032 $this->cfg->lte = $end;
00033 }
00034
00040 public function __toString() {
00041 $tmp = array();
00042
00043 if (!is_null($this->cfg->mt))
00044 $tmp[0] = '('.$this->cfg->name.'>"'.$this->cfg->mt.'")';
00045 if (!is_null($this->cfg->mte) && (is_null($this->cfg->mt) || $this->cfg->mte >= $this->cfg->mt))
00046 $tmp[0] = '('.$this->cfg->name.'>="'.$this->cfg->mte.'")';
00047
00048 if (!is_null($this->cfg->lt))
00049 $tmp[1] = '('.$this->cfg->name.'<"'.$this->cfg->lt.'")';
00050 if (!is_null($this->cfg->lte) && (is_null($this->cfg->lt) || $this->cfg->lte <= $this->cfg->lt))
00051 $tmp[1] = '('.$this->cfg->name.'<="'.$this->cfg->lte.'")';
00052
00053 if (!is_null($this->cfg->eq))
00054 $tmp[] = '('.$this->cfg->name.'="'.$this->cfg->eq.'")';
00055
00056 if (!is_null($this->cfg->df))
00057 $tmp[] = '('.$this->cfg->name.'!="'.$this->cfg->df.'")';
00058
00059 if (!is_null($this->cfg->contains))
00060 $tmp[] = '('.$this->cfg->name.' LIKE "%'.$this->cfg->contains.'%")';
00061
00062 if (!is_null($this->cfg->start))
00063 $tmp[] = '('.$this->cfg->name.' LIKE "'.$this->cfg->start.'%")';
00064
00065 if (!is_null($this->cfg->end))
00066 $tmp[] = '('.$this->cfg->name.' LIKE "%'.$this->cfg->end.'")';
00067
00068 if (!is_null($this->cfg->raw))
00069 $tmp[] = '('.$this->cfg->raw.')';
00070
00071 if (!empty($this->cfg->in)) {
00072 if (is_array($this->cfg->in)) {
00073 $in = $this->cfg->in;
00074 array_walk($in, create_function('&$v', '$v = \'"\'.$v.\'"\';'));
00075 $tmp[] = '('.$this->cfg->name.' IN ('.implode(',', $in).'))';
00076 } else
00077 $tmp[] = '('.$this->cfg->name.' IN ('.$this->cfg->in.'))';
00078 }
00079
00080 if (!empty($this->cfg->freeClause))
00081 $tmp = array_merge($tmp, $this->cfg->freeClause);
00082
00083 return implode(' '.$this->cfg->op.' ', $tmp);
00084 }
00085
00086 }