$sql = "INSERT INTO `table` (`id`, `name`) VALUES (?,?),(?,?) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`) ";//將要批次插入的值放到 (?,?),看你要插入幾組 $values = array(1, "test", 2, "so so");//要插入的值 $stmt = $this->db->prepare($sql);//建立pdo statment $stmt->execute($values);//執行時把要插入的值丟入pdo
http://stackoverflow.com/questions/1176352/pdo-prepared-inserts-multiple-rows-in-single-query
https://gist.github.com/kublaios/007ee6b7b7936c6cd80a
沒有留言:
張貼留言
留個話吧:)