PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $mysqli->query("create table t (id int primary key unique, stat tinyint default 1)"); mysqli_report(MYSQLI_REPORT_OFF); $stmt = $mysqli->stmt_init(); $stmt->prepare("insert into t (id) values(?)"); $id = 3; $stmt->bind_param('i',$id); var_dump($stmt->execute()); $stmt->close(); $stmt = $mysqli->stmt_init(); //var_dump($stmt->prepare("insert into t (id) values(?) RETURNING id;")); var_dump($stmt->prepare("insert into t (id) values(?);")); $id = 3; $stmt->bind_param('i',$i); // Was expecting false since constraint violation. //var_dump($stmt->execute()); $c = 0; while ($c++ < 5 && !$stmt->execute() ) { $stmt->reset(); if ( $c === 2) { $i=8; $stmt->bind_param('i',$i); } } var_dump($c.",".$i); ?>
Show:  
Copy Clear