公共靜態函數 mquery($sql){
$conn = self::db_connect();
$rs=mysqli_query($conn,$sql);
mysqli_close($conn);
公共靜態函數insert($table,$data){
$conn=self::db_connect();
$fields = array();
$values = array();
foreach ($data as $key => $value) {
$value = str_replace(" ' ", '&apos', $value);//單引號替換字元實體
$value = str_replace('"', '"', $value);//雙引號替換
$fields[]= "`".$key."`";
$values[]="'".$value."'";
}
$fields = implode(',', $fields);
$values = implode(',',$values);
/ /sql語句
$sql = "insert into {$table} ({$fields}) Values ({$values})";
# //dump($sql);exit ( );
$insert_id =0;
if (mysqli_query( $conn,$sql)){
$insert_id = mysqli_insert_id($conn);
}
mysqli_close($conn);
return $insert_id;
}
# return $rs;
# }
如果mysqli_query換成self::mquery() mysqli_insert_id (這裡應該傳入什麼呢)