Skip to content

Commit e0cc882

Browse files
committed
Update
1 parent 214fb06 commit e0cc882

File tree

12 files changed

+504
-206
lines changed

12 files changed

+504
-206
lines changed

dist/SuperSQL.php

Lines changed: 145 additions & 59 deletions
Large diffs are not rendered by default.

dist/SuperSQL_advanced.php

Lines changed: 145 additions & 59 deletions
Large diffs are not rendered by default.

dist/SuperSQL_advanced_min.php

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

dist/SuperSQL_helper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
License: MIT (https://github.com/ThreeLetters/SuperSQL/blob/master/LICENSE)
55
Source: https://github.com/ThreeLetters/SQL-Library
66
Build: v1.0.0
7-
Built on: 08/08/2017
7+
Built on: 09/08/2017
88
*/
99

1010

@@ -146,7 +146,7 @@ private static function includes($val,$arr) {
146146
private static function containsAdv($arr) {
147147
foreach ($arr as $key => $val) {
148148
if (gettype($val) == "array") return true;
149-
if (self::includes($key,array("[","#"))) return true;
149+
if (self::includes($key,array("[","#")) || self::includes($val,array("["))) return true;
150150
if (self::includes($val,array("DISTINCT","INSERT INTO","INTO"))) return true;
151151
}
152152
return false;
@@ -225,4 +225,10 @@ function delete($table,$where = array()) {
225225
return $this->s->sDELETE($table,$where);
226226
}
227227
}
228+
function query($a,$b=null) {
229+
return $this->s->con->query($a,$b);
230+
}
231+
function transact($func) {
232+
return $this->s->transact($func);
233+
}
228234
}

dist/SuperSQL_helper_min.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
License: MIT (https://github.com/ThreeLetters/SuperSQL/blob/master/LICENSE)
55
Source: https://github.com/ThreeLetters/SQL-Library
66
Build: v1.0.0
7-
Built on: 08/08/2017
7+
Built on: 09/08/2017
88
*/
99

10-
class SQLHelper{public$s;public$connections;function __construct($a,$b=null,$c=null,$d=null,$e=array()){$this->connections=array();$f=gettype($a);if($f=="array"){if(gettype($a[0])=="array"){foreach($a as$g=>$h){$i=isset($h["host"])?$h["host"]: "";$b=isset($h["db"])?$h["db"]: "";$c=isset($h["user"])?$h["user"]: "";$d=isset($h["password"])?$h["password"]: "";$j=isset($h["options"])?$h["options"]: array();$k=self::connect($i,$b,$c,$d,$j);array_push($this->connections,$k);}}else{foreach($a as$g=>$h){array_push($this->connections,$h);}}$this->s=$this->connections[0];}else if($f=="string"){$this->s=self::connect($a,$b,$c,$d,$e);array_push($this->connections,$this->s);}else{array_push($this->connections,$a);$this->s=$a;}}static function connect($i,$b,$c,$d,$e=array()){$l="mysql";$m=false;if(gettype($e)=="string"){if(strpos($e,":")!==false){$m=$e;}else{$l=strtolower($e);}}else if(isset($e["dbtype"]))$l=strtolower($e["dbtype"]);if(!$m){$n="";switch($l){case "pgsql":$n="pgsql";$o=array("dbname"=>$b,"host"=>$i);if(isset($e["port"]))$o["port"]=$e["port"];break;case "sybase":$n="dblib";$o=array("dbname"=>$b,"host"=>$i);if(isset($e["port"]))$o["port"]=$e["port"];break;case "oracle":$n="oci";$o=array("dbname"=>isset($i)? "//".$i.":".(isset($e["port"])?$e["port"]: "1521")."/".$b :$b);break;default:$n="mysql";$o=array("dbname"=>$b);if(isset($e["socket"]))$o["unix_socket"]=$e["socket"];else{$o["host"]=$i;if(isset($e["port"]))$o["port"]=$e["port"];}break;}$m=$n.":";if(isset($e['charset'])){$o['charset']=$e['charset'];}$m=$n.":";$p=0;foreach($o as$g=>$q){if($p!=0){$m.=";";}$m.=$g."=".$q;$p++;}}return new SuperSQL($m,$c,$d);}private static function rmComments($r){$s=strpos($r,"#");if($s!==false){$r=substr($r,0,$s);}return trim($r);}private static function escape($t){$u=strtolower(gettype($t));if($u=="boolean"){$t=$t ? "1" : "0";}else if($u=="string"){$t="'".$t."'";}else if($u=="double"||$u=="integer"){$t=(int)$t;}else if($u=="null"){$t="0";}return$t;}private static function escape2($t){if(is_numeric($t)){return(int)$t;}else{return "'".$t."'";}}private static function includes($q,$v){foreach($v as$h){if(strpos($q,$h)!==false)return true;}return false;}private static function containsAdv($v){foreach($v as$g=>$q){if(gettype($q)=="array")return true;if(self::includes($g,array("[","#")))return true;if(self::includes($q,array("DISTINCT","INSERT INTO","INTO")))return true;}return false;}function change($w){$this->s=$this->connections[$w];return$this->s;}function getCon($x=false){if($x){return$this->connections;}else{return$this->s;}}function get($y,$z,$aa,$ba=null){$ca=$this->s->SELECT($y,$z,$aa,$ba,1)->getData();return($ca&&$ca[0])?$ca[0]: false;}function create($y,$o){$da="CREATE TABLE `".$y."` (";$s=0;foreach($o as$g=>$q){if($s!=0){$da.=", ";}$da.="`".$g."` ".$q;$s++;}$da.=")";return$this->s->query($da);}function drop($y){return$this->s->query("DROP TABLE `".$y."`");}function replace($y,$o,$aa=array()){$ea=array();foreach($o as$g=>$q){$r="`".self::rmComments($g)."`";foreach($q as$fa=>$h){$r="REPLACE(".$r.", ".self::escape2($fa).", ".self::escape($h).")";}$ea["#".$g]=$r;}return$this->s->UPDATE($y,$ea,$aa);}function select($y,$z=array(),$aa=array(),$ba=null,$ga=false){if(gettype($y)=="array"||self::containsAdv($z)||self::containsAdv($aa)||$ba){return$this->s->SELECT($y,$z,$aa,$ba,$ga);}else{if(gettype($ga)=="integer")$ga="LIMIT ".(int)$ga;return$this->s->sSELECT($y,$z,$aa,$ga);}}function insert($y,$o){if(gettype($y)=="array"||self::containsAdv($o)){return$this->s->INSERT($y,$o);}else{return$this->s->sINSERT($y,$o);}}function update($y,$o,$aa=array()){if(gettype($y)=="array"||self::containsAdv($o)||self::containsAdv($aa)){return$this->s->UPDATE($y,$o,$aa);}else{return$this->s->sUPDATE($y,$o,$aa);}}function delete($y,$aa=array()){if(gettype($y)=="array"||self::containsAdv($aa)){return$this->s->DELETE($y,$aa);}else{return$this->s->sDELETE($y,$aa);}}}
10+
class SQLHelper{public$s;public$connections;function __construct($a,$b=null,$c=null,$d=null,$e=array()){$this->connections=array();$f=gettype($a);if($f=="array"){if(gettype($a[0])=="array"){foreach($a as$g=>$h){$i=isset($h["host"])?$h["host"]: "";$b=isset($h["db"])?$h["db"]: "";$c=isset($h["user"])?$h["user"]: "";$d=isset($h["password"])?$h["password"]: "";$j=isset($h["options"])?$h["options"]: array();$k=self::connect($i,$b,$c,$d,$j);array_push($this->connections,$k);}}else{foreach($a as$g=>$h){array_push($this->connections,$h);}}$this->s=$this->connections[0];}else if($f=="string"){$this->s=self::connect($a,$b,$c,$d,$e);array_push($this->connections,$this->s);}else{array_push($this->connections,$a);$this->s=$a;}}static function connect($i,$b,$c,$d,$e=array()){$l="mysql";$m=false;if(gettype($e)=="string"){if(strpos($e,":")!==false){$m=$e;}else{$l=strtolower($e);}}else if(isset($e["dbtype"]))$l=strtolower($e["dbtype"]);if(!$m){$n="";switch($l){case "pgsql":$n="pgsql";$o=array("dbname"=>$b,"host"=>$i);if(isset($e["port"]))$o["port"]=$e["port"];break;case "sybase":$n="dblib";$o=array("dbname"=>$b,"host"=>$i);if(isset($e["port"]))$o["port"]=$e["port"];break;case "oracle":$n="oci";$o=array("dbname"=>isset($i)? "//".$i.":".(isset($e["port"])?$e["port"]: "1521")."/".$b :$b);break;default:$n="mysql";$o=array("dbname"=>$b);if(isset($e["socket"]))$o["unix_socket"]=$e["socket"];else{$o["host"]=$i;if(isset($e["port"]))$o["port"]=$e["port"];}break;}$m=$n.":";if(isset($e['charset'])){$o['charset']=$e['charset'];}$m=$n.":";$p=0;foreach($o as$g=>$q){if($p!=0){$m.=";";}$m.=$g."=".$q;$p++;}}return new SuperSQL($m,$c,$d);}private static function rmComments($r){$s=strpos($r,"#");if($s!==false){$r=substr($r,0,$s);}return trim($r);}private static function escape($t){$u=strtolower(gettype($t));if($u=="boolean"){$t=$t ? "1" : "0";}else if($u=="string"){$t="'".$t."'";}else if($u=="double"||$u=="integer"){$t=(int)$t;}else if($u=="null"){$t="0";}return$t;}private static function escape2($t){if(is_numeric($t)){return(int)$t;}else{return "'".$t."'";}}private static function includes($q,$v){foreach($v as$h){if(strpos($q,$h)!==false)return true;}return false;}private static function containsAdv($v){foreach($v as$g=>$q){if(gettype($q)=="array")return true;if(self::includes($g,array("[","#"))||self::includes($q,array("[")))return true;if(self::includes($q,array("DISTINCT","INSERT INTO","INTO")))return true;}return false;}function change($w){$this->s=$this->connections[$w];return$this->s;}function getCon($x=false){if($x){return$this->connections;}else{return$this->s;}}function get($y,$z,$aa,$ba=null){$ca=$this->s->SELECT($y,$z,$aa,$ba,1)->getData();return($ca&&$ca[0])?$ca[0]: false;}function create($y,$o){$da="CREATE TABLE `".$y."` (";$s=0;foreach($o as$g=>$q){if($s!=0){$da.=", ";}$da.="`".$g."` ".$q;$s++;}$da.=")";return$this->s->query($da);}function drop($y){return$this->s->query("DROP TABLE `".$y."`");}function replace($y,$o,$aa=array()){$ea=array();foreach($o as$g=>$q){$r="`".self::rmComments($g)."`";foreach($q as$fa=>$h){$r="REPLACE(".$r.", ".self::escape2($fa).", ".self::escape($h).")";}$ea["#".$g]=$r;}return$this->s->UPDATE($y,$ea,$aa);}function select($y,$z=array(),$aa=array(),$ba=null,$ga=false){if(gettype($y)=="array"||self::containsAdv($z)||self::containsAdv($aa)||$ba){return$this->s->SELECT($y,$z,$aa,$ba,$ga);}else{if(gettype($ga)=="integer")$ga="LIMIT ".(int)$ga;return$this->s->sSELECT($y,$z,$aa,$ga);}}function insert($y,$o){if(gettype($y)=="array"||self::containsAdv($o)){return$this->s->INSERT($y,$o);}else{return$this->s->sINSERT($y,$o);}}function update($y,$o,$aa=array()){if(gettype($y)=="array"||self::containsAdv($o)||self::containsAdv($aa)){return$this->s->UPDATE($y,$o,$aa);}else{return$this->s->sUPDATE($y,$o,$aa);}}function delete($y,$aa=array()){if(gettype($y)=="array"||self::containsAdv($aa)){return$this->s->DELETE($y,$aa);}else{return$this->s->sDELETE($y,$aa);}}function query($ha,$p=null){return$this->s->con->query($ha,$p);}function transact($ia){return$this->s->transact($ia);}}
1111
?>

0 commit comments

Comments
 (0)