久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='5Fkc4'></tfoot>

      <bdo id='5Fkc4'></bdo><ul id='5Fkc4'></ul>
    <i id='5Fkc4'><tr id='5Fkc4'><dt id='5Fkc4'><q id='5Fkc4'><span id='5Fkc4'><b id='5Fkc4'><form id='5Fkc4'><ins id='5Fkc4'></ins><ul id='5Fkc4'></ul><sub id='5Fkc4'></sub></form><legend id='5Fkc4'></legend><bdo id='5Fkc4'><pre id='5Fkc4'><center id='5Fkc4'></center></pre></bdo></b><th id='5Fkc4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5Fkc4'><tfoot id='5Fkc4'></tfoot><dl id='5Fkc4'><fieldset id='5Fkc4'></fieldset></dl></div>
    <legend id='5Fkc4'><style id='5Fkc4'><dir id='5Fkc4'><q id='5Fkc4'></q></dir></style></legend>

    <small id='5Fkc4'></small><noframes id='5Fkc4'>

      1. php PDO使用占位符批量插入多行

        php PDO insert batch multiple rows with placeholders(php PDO使用占位符批量插入多行)
          <bdo id='VTJsn'></bdo><ul id='VTJsn'></ul>
        • <legend id='VTJsn'><style id='VTJsn'><dir id='VTJsn'><q id='VTJsn'></q></dir></style></legend>
            <tfoot id='VTJsn'></tfoot>

                    <tbody id='VTJsn'></tbody>

                • <i id='VTJsn'><tr id='VTJsn'><dt id='VTJsn'><q id='VTJsn'><span id='VTJsn'><b id='VTJsn'><form id='VTJsn'><ins id='VTJsn'></ins><ul id='VTJsn'></ul><sub id='VTJsn'></sub></form><legend id='VTJsn'></legend><bdo id='VTJsn'><pre id='VTJsn'><center id='VTJsn'></center></pre></bdo></b><th id='VTJsn'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VTJsn'><tfoot id='VTJsn'></tfoot><dl id='VTJsn'><fieldset id='VTJsn'></fieldset></dl></div>

                  <small id='VTJsn'></small><noframes id='VTJsn'>

                  本文介紹了php PDO使用占位符批量插入多行的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我希望使用 PHP PDO 進(jìn)行多次插入.

                  I am looking to do multiple inserts using PHP PDO.

                  我找到的最接近的答案是這個(gè)

                  The closest answer I have found is this one

                  how-to-insert-an-array-into-a-single-mysql-prepared-statement

                  但是給出的示例使用 ??而不是真正的占位符.

                  However the example thats been given uses ?? instead of real placeholders.

                  我查看了 PHP 文檔站點(diǎn)上的占位符示例

                  I have looked at the examples on the PHP doc site for place holders

                  php.net pdo.prepared-statements

                  $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
                  $stmt->bindParam(':name', $name);
                  $stmt->bindParam(':value', $value);
                  

                  現(xiàn)在假設(shè)我想用數(shù)組實(shí)現(xiàn)上述目標(biāo)

                  Now lets say I wanted to achieve the above but with an array

                  $valuesToInsert = array(
                    0 => array('name' => 'Robert', 'value' => 'some value'),
                    1 => array('name' -> 'Louise', 'value' => 'another value')
                  );
                  

                  對于 PDO 和每個(gè)事務(wù)的多個(gè)插入,我將如何處理?

                  我想它會從一個(gè)循環(huán)開始?

                  I imagine it would start of with a loop?

                  $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
                  
                  foreach($valuesToInsert as $insertRow){
                  
                      // now loop through each inner array to match binded values
                      foreach($insertRow as $column => value){
                          $stmt->bindParam(":{$column}", value);
                      }
                  }
                  $stmt->execute();
                  

                  然而,上述方法不起作用,但希望能證明我試圖實(shí)現(xiàn)的目標(biāo)

                  However the above does not work but hopefully will demonstrate what im trying to achieve

                  推薦答案

                  首先,? 符號真正的占位符(大多數(shù)驅(qū)動程序允許同時(shí)使用這兩種語法,位置和命名占位符).其次,準(zhǔn)備好的語句只不過是一種將原始輸入注入到 SQL 語句中的工具——SQL 語句本身的語法不受影響.您已經(jīng)擁有所需的所有元素:

                  First of all, ? symbols are real place-holders (most drivers allow to use both syntaxes, positional and named place-holders). Secondly, prepared statements are nothing but a tool to inject raw input into SQL statements—the syntax of the SQL statement itself is unaffected. You already have all the elements you need:

                  • 如何使用單個(gè)查詢插入多行
                  • 如何動態(tài)生成 SQL
                  • 如何使用帶有命名占位符的預(yù)處理語句.

                  將它們?nèi)拷Y(jié)合起來非常簡單:

                  It's fairly trivial to combine them all:

                  $sql = 'INSERT INTO table (memberID, programID) VALUES ';
                  $insertQuery = [];
                  $insertData = [];
                  $n = 0;
                  foreach ($data as $row) {
                      $insertQuery[] = '(:memberID' . $n . ', :programID' . $n . ')';
                      $insertData['memberID' . $n] = $memberid;
                      $insertData['programID' . $n] = $row;
                      $n++;
                  }
                  
                  if (!empty($insertQuery)) {
                      $sql .= implode(', ', $insertQuery);
                      $stmt = $db->prepare($sql);
                      $stmt->execute($insertData);
                  }
                  

                  這篇關(guān)于php PDO使用占位符批量插入多行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準(zhǔn)備好的語句amp;foreach 循環(huán))
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個(gè)服務(wù)器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個(gè)參數(shù))
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結(jié)果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)

                  <small id='UXpXA'></small><noframes id='UXpXA'>

                  <tfoot id='UXpXA'></tfoot>

                  1. <legend id='UXpXA'><style id='UXpXA'><dir id='UXpXA'><q id='UXpXA'></q></dir></style></legend>

                        <tbody id='UXpXA'></tbody>
                        <bdo id='UXpXA'></bdo><ul id='UXpXA'></ul>

                            <i id='UXpXA'><tr id='UXpXA'><dt id='UXpXA'><q id='UXpXA'><span id='UXpXA'><b id='UXpXA'><form id='UXpXA'><ins id='UXpXA'></ins><ul id='UXpXA'></ul><sub id='UXpXA'></sub></form><legend id='UXpXA'></legend><bdo id='UXpXA'><pre id='UXpXA'><center id='UXpXA'></center></pre></bdo></b><th id='UXpXA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='UXpXA'><tfoot id='UXpXA'></tfoot><dl id='UXpXA'><fieldset id='UXpXA'></fieldset></dl></div>
                            主站蜘蛛池模板: 国产午夜精品一区二区 | 日韩欧美在线视频 | www.亚洲精品| 日本三级做a全过程在线观看 | 偷拍自拍网 | 成人亚洲网站 | 国产一区二区视频免费在线观看 | 99精品观看 | 午夜电影福利 | 激情毛片 | 日韩国产一区二区 | 欧美激情久久久 | 欧美一区二区三区久久精品视 | 黄色毛片在线看 | 精品亚洲二区 | 91精品国产色综合久久不卡蜜臀 | 亚洲一区二区精品视频在线观看 | 在线国产一区二区 | 91精品一区 | 亚洲国产在 | 免费av观看| 久久日韩精品一区二区三区 | 好姑娘影视在线观看高清 | 午夜网| 欧美精品一区二区三区在线播放 | 欧美日韩久久 | 91爱爱·com| 欧美一级大片免费观看 | 国产粉嫩尤物极品99综合精品 | 在线播放中文字幕 | 日韩喷潮 | 夜久久 | 欧美男男videos | 久久久久久国产精品免费免费男同 | 波多野结衣精品在线 | 日韩欧美一区二区三区 | 夜夜草 | 免费精品视频 | 亚洲在线一区二区 | 99福利视频 | 黄色欧美大片 |