插入:

<?php
$conn=@new mysqli('localhost','root','123','mytestdb');
$q_str=<<<EOM
insert into users(name,email,date)values('xiaoxue','xue@163.com',now());
EOM;
$result=@$conn->query($q_str);
if($result===false){
	echo "Connect Failed with:$conn->error<br/>\n";
	$conn->close();
	exit;
}else{
	echo "Create new user with id:{$conn->insert_id}";
}
?>

可以查询mysqli类的insert_id属性

更新:

<?php
$conn=@new mysqli('localhost','root','123','mytestdb');
$q_str=<<<EOM
update users set name='jian' where id=7;
EOM;
$result=@$conn->query($q_str);
if($result===false){
	echo "Connect Failed with:$conn->error<br/>\n";
	$conn->close();
	exit;
}else{
	echo "I modified {$conn->affected_rows} rows.<br/>\n";
}
?>

 可以查询mysqli类的affected_rows属性。 

 

相关文章:

  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2021-11-26
  • 2021-11-09
  • 2021-11-07
  • 2022-12-23
  • 2021-08-29
猜你喜欢
  • 2021-07-28
  • 2022-12-23
  • 2021-11-24
  • 2021-12-13
  • 2021-08-25
  • 2021-12-12
  • 2021-08-12
相关资源
相似解决方案