|
|
@@ -62,6 +62,7 @@ class MyPdo {
|
|
|
public function __construct(){
|
|
|
global $mylog;
|
|
|
$this->log = $mylog;
|
|
|
+// $this->dbconnect();
|
|
|
}
|
|
|
public function dbconnect($hostname, $username, $password, $database, $prefix) {
|
|
|
$dsn = 'mysql:dbname='.$database.';host='.$hostname.';port=3306';
|
|
|
@@ -69,8 +70,10 @@ class MyPdo {
|
|
|
$mypdo = new PDO($dsn, $username, $password);
|
|
|
$mypdo -> query('set names utf8;');
|
|
|
$mypdo -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
+
|
|
|
$this->pdo = $mypdo;
|
|
|
$this->prefix = $prefix;
|
|
|
+// var_dump($this);
|
|
|
return $this;
|
|
|
} catch(PDOException $e) {
|
|
|
if($this->debug) echo $e->getMessage();
|
|
|
@@ -165,6 +168,7 @@ class MyPdo {
|
|
|
|
|
|
|
|
|
public function sqlinsert($table, $param){
|
|
|
+
|
|
|
if(!is_array($param)){
|
|
|
throw new Exception('sqlinsert参数错误', 905);
|
|
|
}
|
|
|
@@ -180,7 +184,7 @@ class MyPdo {
|
|
|
}
|
|
|
$params_str = implode(',', $params);
|
|
|
$sql .= $params_str.')';
|
|
|
-var_dump($sql);
|
|
|
+//var_dump($sql);
|
|
|
try {
|
|
|
$this->pdo->exec($sql);
|
|
|
|
|
|
@@ -188,7 +192,6 @@ var_dump($sql);
|
|
|
if($this->logSQL) {
|
|
|
$this->log->debug($sql, 0);
|
|
|
}
|
|
|
-
|
|
|
return $this->getLastId();
|
|
|
} catch(PDOException $e) {
|
|
|
$msg = $e->getMessage().'【错误的SQL语句:'.$sql.'】';
|