Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select the last affected rows

Tags:

php

select

mysqli

I have updated my records based on specific condition after that I want to know the ids from the affected rows.

$sql = mysqli_query("update table set xxx='".$x."' where yyy='".$y."'");

Now after executing this query I want to know the affected rows.

like image 627
Vamshi .goli Avatar asked Apr 21 '15 08:04

Vamshi .goli


1 Answers

Simple yet effective

$last_id = mysqli_insert_id($conn);

http://www.w3schools.com/php/php_mysql_insert_lastid.asp

like image 109
kayleighsdaddy Avatar answered Oct 14 '22 05:10

kayleighsdaddy