กรณีที่ต้อง insert หลายๆ ค่าพร้อมกันในคำสั่งเดียว
ตัวอย่างโค้ด
ใช้ฟังก์ชั่น
โค้ด: เลือกทั้งหมด
string dbal::sql_multi_insert ( string $table , array $sql_ary ] )
โค้ด: เลือกทั้งหมด
$sql_ary = array(
// One row
array(
'somedata' => 'row 1',
'otherdata' => 'otherdata 1',
'moredata' => 'moredata 1'
),
// Anther row
array(
'somedata' => 'row 2',
'otherdata' => 'otherdata 2',
'moredata' => 'moredata 2'
)
);
$db->sql_multi_insert(SOME_TABLE, $sql_ary);
ทิปเทคนิคการเขียน PHP ดีๆ ดูต่อที่นี่นะ
https://www.mindphp.com/developer/26-%E ... 9-php.html
PHP กับเรื่องความปลอดภัยก็ไม่ควรมองข้ามนะดูต่อที่นี่
https://www.mindphp.com/developer/80-php-security.html