Jump to content


Photo

Odd behavior with mysqli's autocommit


  • Please log in to reply
No replies to this topic

#1 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 05 July 2006 - 07:11 PM

The code for this was taken from the manual page for mysqli_autocommit, with an additional test added to turn autocommit off.

I am testing this on 2 boxes:
1. Windows, PHP 5.1.2, MySQL 5.0.18
2. Unix, PHP 5.1.4, MySQL 5.0.20a

The code gives the following results:
1. Windows: "Autocommit is 1 Autocommit is 0"
2. Unix: "Autocommit is 1 Autocommit is 1"

Interestingly enough, if I replace $mysqli->autocommit(FALSE); with $mysqli->query('set autocommit = 0'); it works.

Has anyone seen this before, or worked with autocommit?

Thanks.

<?php
	$mysqli = new mysqli("localhost", "---", "---");

	if (mysqli_connect_errno()) {
	   printf("Connect failed: %s\n", mysqli_connect_error());
	   exit();
	}

	/* turn autocommit on */
	$mysqli->autocommit(TRUE);

	if ($result = $mysqli->query("SELECT @@autocommit")) {
	   $row = $result->fetch_row();
	   printf("Autocommit is %s\n", $row[0]);
	   $result->free();
	}

	/* turn autocommit off */
	$mysqli->autocommit(FALSE);

	if ($result = $mysqli->query("SELECT @@autocommit")) {
	   $row = $result->fetch_row();
	   printf("Autocommit is %s\n", $row[0]);
	   $result->free();
	}
	
	/* close connection */
	$mysqli->close();
?>

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users