|
 |
|
เคยใช้ INSERT ... ON DUPLICATE KEY หรือ INSERT IGNORE บ้างครับ |
|
 |
|
|
 |
 |
|
ลงซ้ำอยู่ครับ ผม ตั้ง id เปน auto นะ
Code (PHP)
[php]$sql="INSERT IGNORE INTO new2 VALUES(null,'".mysql_real_escape_string($title)."','".mysql_real_escape_string($desc)."','$pub',now(),'$url','$img_new')";
|
ประวัติการแก้ไข 2011-07-18 16:13:48 2011-07-18 16:23:12 2011-07-18 16:52:41 2011-07-20 00:27:18
 |
 |
 |
 |
Date :
2011-07-18 16:08:17 |
By :
ckcr |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวนี้มันเชคจาก Key น่ะครับ Primary/UNIQUE
|
 |
 |
 |
 |
Date :
2011-07-18 16:16:52 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
insert ignore into test_warnings (id_, num_) values (?,?) อันนี้ผมก็ทำถูกแล้วใช่เปล่าครับ หรือว่าต้องมีid ด้วยครับ
|
 |
 |
 |
 |
Date :
2011-07-18 21:07:03 |
By :
ckcr |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองไปดู field ทุกตัวนะครับ ใน base ว่ามีตั้ง ตัวไหนเป็น FK (ฟอเร้นkey รึป่าว)
|
 |
 |
 |
 |
Date :
2011-07-19 17:52:10 |
By :
teez1232002 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ซ้ำตั้งเป็น unique แล้วตอน insert ใช้คำสั่ง ignore ลงไปเพื่อไม่ให้ Error
เข้าใจอย่างลึกซึ่งแล้ว
|
ประวัติการแก้ไข 2011-07-20 00:27:57 2011-07-21 16:50:18
 |
 |
 |
 |
Date :
2011-07-19 21:59:36 |
By :
ckcr |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|