nyroFwk  0.2
whereClause.class.php
Go to the documentation of this file.
1 <?php
10 class db_whereClause extends object {
11 
15  public function __set($name, $val) {
16  $this->cfg->set($name, $val);
17  }
18 
22  public function between($st, $end) {
23  $this->cfg->mt = $st;
24  $this->cfg->lt = $end;
25  }
26 
30  public function betweenEq($st, $end) {
31  $this->cfg->mte = $st;
32  $this->cfg->lte = $end;
33  }
34 
40  public function __toString() {
41  $tmp = array();
42 
43  if (!is_null($this->cfg->mt))
44  $tmp[0] = '('.$this->cfg->name.'>"'.$this->cfg->mt.'")';
45  if (!is_null($this->cfg->mte) && (is_null($this->cfg->mt) || $this->cfg->mte >= $this->cfg->mt))
46  $tmp[0] = '('.$this->cfg->name.'>="'.$this->cfg->mte.'")';
47 
48  if (!is_null($this->cfg->lt))
49  $tmp[1] = '('.$this->cfg->name.'<"'.$this->cfg->lt.'")';
50  if (!is_null($this->cfg->lte) && (is_null($this->cfg->lt) || $this->cfg->lte <= $this->cfg->lt))
51  $tmp[1] = '('.$this->cfg->name.'<="'.$this->cfg->lte.'")';
52 
53  if (!is_null($this->cfg->eq))
54  $tmp[] = '('.$this->cfg->name.'="'.$this->cfg->eq.'")';
55 
56  if (!is_null($this->cfg->df))
57  $tmp[] = '('.$this->cfg->name.'!="'.$this->cfg->df.'")';
58 
59  if (!is_null($this->cfg->contains))
60  $tmp[] = '('.$this->cfg->name.' LIKE "%'.$this->cfg->contains.'%")';
61 
62  if (!is_null($this->cfg->start))
63  $tmp[] = '('.$this->cfg->name.' LIKE "'.$this->cfg->start.'%")';
64 
65  if (!is_null($this->cfg->end))
66  $tmp[] = '('.$this->cfg->name.' LIKE "%'.$this->cfg->end.'")';
67 
68  if (!is_null($this->cfg->raw))
69  $tmp[] = '('.$this->cfg->raw.')';
70 
71  if (!empty($this->cfg->in)) {
72  if (is_array($this->cfg->in)) {
73  $in = $this->cfg->in;
74  array_walk($in, create_function('&$v', '$v = \'"\'.$v.\'"\';'));
75  $tmp[] = '('.$this->cfg->name.' IN ('.implode(',', $in).'))';
76  } else
77  $tmp[] = '('.$this->cfg->name.' IN ('.$this->cfg->in.'))';
78  }
79 
80  if (!empty($this->cfg->freeClause))
81  $tmp = array_merge($tmp, $this->cfg->freeClause);
82 
83  return implode(' '.$this->cfg->op.' ', $tmp);
84  }
85 
86 }
__set($name, $val)
betweenEq($st, $end)
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13