-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisi
2 lines (2 loc) · 2.2 KB
/
isi
1
2
<?php
class isi extends PDO{function __construct(){require_once 'config.php';extract($connect);parent::__construct("mysql:host=$host;dbname=$dbname","$user","$password");}function field($b){$c=$this->prepare("DESCRIBE ".$b);$c->execute();$d=$c->fetchAll(PDO::FETCH_ASSOC);return $d;}function create($b,$e=array()){$this->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);if(empty($e)){$f=$this->field($b);foreach($f as $g){if($g['Type']!='timestamp'){$e[$g['Field']]=$_REQUEST[$g['Field']];}}}$h=implode(",",array_keys($e));$i=":".implode(",:",array_keys($e));$j=implode(",",$e);$k="INSERT INTO $b($h) VALUES($j)";$c=$this->prepare("INSERT INTO $b($h) VALUES($i)");if(!$c){$l=$this->errorInfo();echo $l[2]."<br>please check this query ⇒".$k;die();}else{foreach($e as $m=>$n){$c->bindValue(":$m",$n);}$c->execute();}}function read($b,$o=null,$h="*"){$this->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);$k="SELECT $h FROM $b $o";$c=$this->prepare($k);if(!$c){$l=$this->errorInfo();echo $l[2]."<br>please check this query ⇒".$k;die();}else{$c->execute();$d=$c->fetchAll(PDO::FETCH_ASSOC);return $d;}}function update($b,$p,$e=array()){if(empty($e)){$f=$this->field($b);foreach($f as $g){if($g['Type']!='timestamp'){$n[]=$g['Field']."=:".$g['Field'];$e[$g['Field']]=$_REQUEST[$g['Field']];}}}else{foreach($e as $m=>$j){$n[]=$m."=:".$m;}}$i=implode(",",$n);$c=$this->prepare("UPDATE $b SET $i WHERE $p");if(!$c){$this->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);$l=$this->errorInfo();echo $l[2];die();}else{foreach($e as $m=>$n){$c->bindValue(":$m",$n);}$c->execute();}}function delete($b,$p){$this->exec("DELETE FROM $b WHERE $p");}function upload($e,$q,$r=NULL){$s=$_FILES[$e];$t=$s['name'];move_uploaded_file($s['tmp_name'],"$q/".$t);if(!is_null($r)){$u=explode(".",$t);$r=$r.".".end($u);rename("$q/".$t,"$q/".$r);$s['name']=$r;$t=$r;}chmod("$q/".$t,0777);return $s;}function one($b,$o=null,$h="*"){$this->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);$k="SELECT $h FROM $b $o";$c=$this->prepare($k);if(!$c){$l=$this->errorInfo();echo $l[2]."<br>please check this query ⇒".$k;die();}else{$c->execute();$d=$c->fetch(PDO::FETCH_ASSOC);return $d;}}function redirect($v){echo '<meta http-equiv="refresh" content="0; url='.$v.'" />';}}?>