$ mysqli-> info is null after one row is successfully inserted

After entering multiple lines with a single insert statement, I get the expected behavior from $ mysqli-> info.

var_dump( $mysqli->info );
string 'Records: 1246  Duplicates: 0  Warnings: 0' (length=41)

After inserting one row, $ mysqli-> info returns NULL

var_dump( $mysqli->info );
null
var_dump( $mysqli->affected_rows );
int 1

mysqli_info () returns an empty string

var_dump( mysqli_info( $mysqli ) )
string '' (length=0)

I can not find a link to this behavior! I would expect information after one insert, for example

string 'Records: 1  Duplicates: 0  Warnings: 0' (length=38)

PHP 5.4.12, mySQL 5.6.12

Executed code:

$sql = "INSERT INTO module_history (BackupDate, Modules) VALUES ('2014-01-01','Module List1')";
$db->query($sql);
echo $sql . "\n";
var_dump( $db->info );
var_dump( $db->affected_rows );

$sql = "INSERT INTO module_history (BackupDate, Modules) VALUES ('2014-01-02','Module List2'),('2014-01-03','Module List3')";
$db->query($sql);
echo $sql . "\n";
var_dump( $db->info );
var_dump( $db->affected_rows );

Results:

INSERT INTO module_history (BackupDate, Modules) VALUES ('2014-01-01','Module List1')
null
int 1
INSERT INTO module_history (BackupDate, Modules) VALUES ('2014-01-02','Module List2'),('2014-01-03','Module List3')
string 'Records: 2  Duplicates: 0  Warnings: 0' (length=38)
int 2
+4
source share
1 answer

http://dev.mysql.com/doc/apis-php/en/apis-php-mysqli.info.html

Table 3.9 Possible values ​​returned by mysqli_info

Request Type - Example Result String

  • INSERT INTO ... SELECT ... Entries: 100 Duplicates: 0 Warnings: 0
  • INSERT INTO... VALUES (...), (...), (...) : 3 : 0 : 0
  • LOAD DATA INFILE... : 1 : 0 : 0 : 0
  • ALTER TABLE... : 3 : 0 : 0
  • UPDATE... : 40 : 40 : 0

, , . mysqli_info .


: . - , .

+3

Source: https://habr.com/ru/post/1533358/


All Articles