sql mit einem param muss nicht mehr mit array geschrieben werden
This commit is contained in:
parent
f736789f5b
commit
32c65f7da1
38
sql.php
38
sql.php
@ -9,13 +9,13 @@ class SQL {
|
|||||||
public $cnt_set = 0;
|
public $cnt_set = 0;
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
require_once ('secret.php');
|
require_once ('secret.php');
|
||||||
|
|
||||||
$this->m = $_m;
|
$this->m = $_m;
|
||||||
$this->pre = $_m ['pre'];
|
$this->pre = $_m ['pre'];
|
||||||
$this->salt = $_m ['salt'];
|
$this->salt = $_m ['salt'];
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
$this->f = fopen ( 'sql.log', 'w' );
|
$this->f = fopen ( 'sql.log', 'w' );
|
||||||
|
|
||||||
$this->h = new mysqli ( $_m ['host'], $_m ['user'], $_m ['pass'], $_m ['data'] );
|
$this->h = new mysqli ( $_m ['host'], $_m ['user'], $_m ['pass'], $_m ['data'] );
|
||||||
if ($this->h->connect_errno) {
|
if ($this->h->connect_errno) {
|
||||||
return false;
|
return false;
|
||||||
@ -27,18 +27,22 @@ class SQL {
|
|||||||
$this->cnt_get ++;
|
$this->cnt_get ++;
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
fputs ( $this->f, str_replace ( array (
|
fputs ( $this->f, str_replace ( array (
|
||||||
"\n",
|
"\n",
|
||||||
" "
|
" "
|
||||||
), array (
|
), array (
|
||||||
' ',
|
' ',
|
||||||
''
|
''
|
||||||
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
||||||
$statement = $this->h->prepare ( $que );
|
$statement = $this->h->prepare ( $que );
|
||||||
switch (count ( $p )) {
|
switch (count ( $p )) {
|
||||||
case 0 :
|
case 0 :
|
||||||
break;
|
break;
|
||||||
case 1 :
|
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;
|
break;
|
||||||
case 2 :
|
case 2 :
|
||||||
$statement->bind_param ( $t, $p [0], $p [1] );
|
$statement->bind_param ( $t, $p [0], $p [1] );
|
||||||
@ -69,9 +73,9 @@ class SQL {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$statement->execute ();
|
$statement->execute ();
|
||||||
|
|
||||||
$ret = array ();
|
$ret = array ();
|
||||||
|
|
||||||
// print_r($statement);
|
// print_r($statement);
|
||||||
if (isset ( $statement->error ) && $statement->error != '') {
|
if (isset ( $statement->error ) && $statement->error != '') {
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
@ -122,17 +126,21 @@ class SQL {
|
|||||||
$statement = $this->h->prepare ( $que );
|
$statement = $this->h->prepare ( $que );
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
fputs ( $this->f, str_replace ( array (
|
fputs ( $this->f, str_replace ( array (
|
||||||
"\n",
|
"\n",
|
||||||
" "
|
" "
|
||||||
), array (
|
), array (
|
||||||
' ',
|
' ',
|
||||||
''
|
''
|
||||||
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
||||||
switch (count ( $p )) {
|
switch (count ( $p )) {
|
||||||
case 0 :
|
case 0 :
|
||||||
break;
|
break;
|
||||||
case 1 :
|
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;
|
break;
|
||||||
case 2 :
|
case 2 :
|
||||||
$statement->bind_param ( $t, $p [0], $p [1] );
|
$statement->bind_param ( $t, $p [0], $p [1] );
|
||||||
@ -183,7 +191,7 @@ class SQL {
|
|||||||
fputs ( $this->f, $statement->error );
|
fputs ( $this->f, $statement->error );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
return $statement->insert_id;
|
return $statement->insert_id;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user