2012-07-03 2 views
2

어떤 정보를 삽입 오류는, 내가 그것을 작동하게했다,하지만 오류없이 삽입 된 행이 없습니다 :MySQLi 작동하지 않습니다, 나는 모든 사람을 해왔

어떤 생각? 당신은 autocommit(FALSE)을 지정하지만, 한

 if($stmt = $this->db->prepare("INSERT INTO Users (id,email) VALUES (?, ?)")) 
     { 
      $test1 = 1; //Empty 
      $test2 = '[email protected]'; //Empty 
      $stmt->bind_param("is", $test1, $test2); 
      $stmt->execute(); 
      if (false===$stmt) 
      { 
       die('execute() failed: ' . htmlspecialchars($mysqli->error)); 
      }    
      $stmt -> close(); 
     } 
     else 
     { 
      printf("Prepared Statement Error: %s\n", $this->db->error); 
     } 
     echo 'Any Errors: '.$this->db->error.PHP_EOL; 
+3

당신이 지정했기 때문에 [''(FALSE) 자동 커밋 (http://www.php.net/manual/en/mysqli.autocommit.php) 여기서 거래를 [수동 커밋] (http://php.net/manual/en/mysqli.commit.php)합니까? – eggyal

답변

6

private $db; 

// Constructor - open DB connection 
function __construct() 
{ 
    $this->db = new mysqli('localhost', 'root', '', 'sampleinyoudb'); 
    $this->db->autocommit(FALSE); 

    if (mysqli_connect_errno()) 
    { 
     sendResponse(500, "Could not connect to the database!"); 
     exit(); 
    } 
} 

// Destructor - close DB connection 
function __destruct() 
{ 
    $this->db->close(); 
} 

은 ... manually committing 거래하지 않습니다. $stmt->execute() 후 어떤 시점에서 당신은 넣어해야합니다

$this->db->commit(); 
+0

내 날 (밤)에 저장되었습니다. – javsmo

관련 문제