I have simple code. This query works fine. It works directly through sql and from php too (changed $mysqli->query
to $mysqli->multi_query
to make it work from php) but it $mysqli->affected_rows
return 0
. There are actually inserted rows and when I run it the query through heidisql it reports:
Affected rows: 2 Found rows: 0 Warnings: 0 Duration for 2 queries: 0.000 sec.
How am I supposed to count affected rows? What am I doing wrong?
I tried also rowCount() and didn't really helped.
include ("../connect.php");
$sql = "SELECT balance INTO @b
FROM managerstock
WHERE ID = LAST_INSERT_ID();
INSERT INTO managerstock (`inOut`, quantity, balance)
VALUES (1, 1, 3);";
if($result = $mysqli->multi_query($sql)){
echo $mysqli->affected_rows;
}