eval("\$value=array$regs[3];"); for($i=0;$i<count($key);$i++) $rs[$key[$i]] = $value[$i]; $this->conn[$regs[1]][] = $rs; $this->_close(); } function _update($query) { eregi("update +([0-9a-z_]+) +set *(,?.*=.*)+( +where +(.+))",$query,$regs); $regs[2] = eregi_replace(",","=",$regs[2]); $v = split("=",$regs[2]); $keys = $this->_where($regs[4],"\$this->conn[$regs[1]]"); while(list($key,$value) = each($keys)) { for($i=0;$i<count($v);$i+=2) $this->conn[$regs[1]][$value][$v[$i]] = eregi_replace("'","",$v[$i+1]); } $this->_close(); } function _delete($query) { eregi("delete +from +([0-9a-z_]+) *(where +(.+))?",$query,$regs); $keys = $this->_where($regs[3],"\$this->conn[$regs[1]]"); while(list($key,$value) = each($keys)) { unset($this->conn[$regs[1]][$value]); } reset($this->conn[$regs[1]]); while(list($key,$value) = each($this->conn[$regs[1]])) { $ch[] = $value; } $this->conn[$regs[1]] = $ch; $this->_close(); } function _where($search,$table) { $search = eregi_replace("\("," ( ",$search); $search = eregi_replace("\)"," ) ",$search); $search = eregi_replace("\+"," + ",$search); $search = eregi_replace("\*"," * ",$search); while(eregi("[^ ]([*/><!=-])",$search,$regs)) { $search = eregi_replace($regs[1]," $regs[1] ",$search); } while(eregi("([><!] +=)",$search,$regs)) { $search = eregi_replace($regs[1],eregi_replace(" ","",$regs[1]),$search); } $search = eregi_replace(" "," ",trim($search)); $search = eregi_replace(" and "," && ",$search); $search = eregi_replace(" or "," || ",$search); $search = eregi_replace(" = "," == ",$search); $ar = split(" ",$search); eval("\$t=$table;");
for($i=0;$i<count($ar);$i++) { if(isset($t[0][$ar[$i]])) $ar[$i] = "\$value[".$ar][$i]."]"; } $expr = "\$expl=(".join(" ",$ar).");"; while(list($key,$value) = each($t)) { eval($expr); if($expl) |