diff --git a/sql.php b/sql.php index ff7d062..851a618 100644 --- a/sql.php +++ b/sql.php @@ -9,13 +9,13 @@ class SQL { public $cnt_set = 0; public function __construct() { require_once ('secret.php'); - + $this->m = $_m; $this->pre = $_m ['pre']; $this->salt = $_m ['salt']; if (SQL_LOG) $this->f = fopen ( 'sql.log', 'w' ); - + $this->h = new mysqli ( $_m ['host'], $_m ['user'], $_m ['pass'], $_m ['data'] ); if ($this->h->connect_errno) { return false; @@ -27,18 +27,22 @@ class SQL { $this->cnt_get ++; if (SQL_LOG) fputs ( $this->f, str_replace ( array ( - "\n", - " " + "\n", + " " ), array ( - ' ', - '' + ' ', + '' ), $que ) . "\n" . print_r ( $p, true ) . "\n\n" ); $statement = $this->h->prepare ( $que ); switch (count ( $p )) { case 0 : break; case 1 : - $statement->bind_param ( $t, $p [0] ); + if (is_array ( $p )) { + $statement->bind_param ( $t, $p [0] ); + } else { + $statement->bind_param ( $t, $p ); + } break; case 2 : $statement->bind_param ( $t, $p [0], $p [1] ); @@ -69,9 +73,9 @@ class SQL { break; } $statement->execute (); - + $ret = array (); - + // print_r($statement); if (isset ( $statement->error ) && $statement->error != '') { if (SQL_LOG) @@ -122,17 +126,21 @@ class SQL { $statement = $this->h->prepare ( $que ); if (SQL_LOG) fputs ( $this->f, str_replace ( array ( - "\n", - " " + "\n", + " " ), array ( - ' ', - '' + ' ', + '' ), $que ) . "\n" . print_r ( $p, true ) . "\n\n" ); switch (count ( $p )) { case 0 : break; case 1 : - $statement->bind_param ( $t, $p [0] ); + if (is_array ( $p )) { + $statement->bind_param ( $t, $p [0] ); + } else { + $statement->bind_param ( $t, $p ); + } break; case 2 : $statement->bind_param ( $t, $p [0], $p [1] ); @@ -183,7 +191,7 @@ class SQL { fputs ( $this->f, $statement->error ); return false; } - + if ($id) { return $statement->insert_id; } else {