Skip to content

Instantly share code, notes, and snippets.

@chobie
Created October 15, 2010 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chobie/627733 to your computer and use it in GitHub Desktop.
Save chobie/627733 to your computer and use it in GitHub Desktop.
Doctrine2とmysqliでのインサートの比較用
<?php
// 本番環境ではやらないでね!
$mysqli = mysqli_init();
$mysqli->real_connect("localhost","user_name","password","db_name");
if($error = mysqli_connect_error()){
throw new RuntimeException($error);
}
$mysqli->set_charset("utf8");
$name = "Guilherme";
$s = microtime(true);
$stmt = $mysqli->prepare("insert into users(name) values(?)");
$stmt->bind_param("s",$name);
$mysqli->query("start transaction");
for($i =0;$i<10000;$i++){
$stmt->execute();
}
$mysqli->commit();
$e = microtime(true);
echo ($e - $s) . PHP_EOL;
$mysqli->query("truncate users");
$mysqli->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment