<?php
$sql 
= "insert ignore into sometable set num=10";
mysql_query($sql) or die();
echo 
mysql_affected_rows()."<br>";
echo 
mysql_insert_id()."<br><br>";

// same record, database is unique on 'num'
$sql = "insert ignore into sometable set num=10";
mysql_query($sql) or die();
echo 
mysql_affected_rows()."<br>";
echo 
mysql_insert_id()."<br><br>";
?>

would give:
1
116372

0
116373


출처 : PHP

+ Recent posts