PDO Prepared Inserts multiple rows in single query

后端 未结 22 2049
感情败类
感情败类 2020-11-21 23:38

I am currently using this type of SQL on MySQL to insert multiple rows of values in one single query:

INSERT INTO `tbl` (`key1`,`key2`) VALUES (\'r1v1\',\'r1         


        
22条回答
  •  甜味超标
    2020-11-21 23:42

    Here is my solution: https://github.com/sasha-ch/Aura.Sql based on auraphp/Aura.Sql library.

    Usage example:

    $q = "insert into t2(id,name) values (?,?), ... on duplicate key update name=name"; 
    $bind_values = [ [[1,'str1'],[2,'str2']] ];
    $pdo->perform($q, $bind_values);
    

    Bugreports are welcome.

提交回复
热议问题