If mysqli_query is encapsulated, is there any way to use mysqli_insert_id?
星火
星火 2018-10-14 07:38:59
0
1
1229

public static function mquery($sql){

$conn = self::db_connect();

$rs=mysqli_query($conn,$sql);

mysqli_close($conn);

public static function 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;

}


星火
星火

reply all(1)
星火

If mysqli_query is replaced with self::mquery() mysqli_insert_id (what should be passed in here)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template