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

      <legend id='DqeDK'><style id='DqeDK'><dir id='DqeDK'><q id='DqeDK'></q></dir></style></legend>

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

          <bdo id='DqeDK'></bdo><ul id='DqeDK'></ul>

      1. php+mysql:在mysql中插入一个php数组

        php+mysql: insert a php array into mysql(php+mysql:在mysql中插入一个php数组)
        <tfoot id='43h0y'></tfoot>
      2. <small id='43h0y'></small><noframes id='43h0y'>

              1. <legend id='43h0y'><style id='43h0y'><dir id='43h0y'><q id='43h0y'></q></dir></style></legend>
                <i id='43h0y'><tr id='43h0y'><dt id='43h0y'><q id='43h0y'><span id='43h0y'><b id='43h0y'><form id='43h0y'><ins id='43h0y'></ins><ul id='43h0y'></ul><sub id='43h0y'></sub></form><legend id='43h0y'></legend><bdo id='43h0y'><pre id='43h0y'><center id='43h0y'></center></pre></bdo></b><th id='43h0y'></th></span></q></dt></tr></i><div id='43h0y'><tfoot id='43h0y'></tfoot><dl id='43h0y'><fieldset id='43h0y'></fieldset></dl></div>
                  <tbody id='43h0y'></tbody>
                  <bdo id='43h0y'></bdo><ul id='43h0y'></ul>

                • 本文介绍了php+mysql:在mysql中插入一个php数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含 30000 多个条目的数组,需要进入 MySQL 表.

                  I have an array with 30000 plus entries that need to go into a MySQL table.

                  最佳做法是什么?从这里?假设数据库中的 [0]、[1] 和 [2] 将是标题"、类型"和客户"

                  What is the best practice? From here? Lets say [0], [1] and [2] in the database would be 'title', 'type' and 'customer'

                  是否添加与表中的列名匹配的键名并调用som魔术"函数?或者手动构建查询...

                  Is it add key names matching the column names in the table and call som "magic" function? Or build the query manually...

                  Array
                  (
                      [0] => Array
                          (
                              [0] => 2140395946
                              [1] => 1SAP
                              [2] => 0041451463
                          )
                  
                      [1] => Array
                          (
                              [0] => 2140411607
                              [1] => 2SAP
                              [2] => 0041411940
                          )
                  
                      [2] => Array
                          (
                              [0] => 2140706194
                              [1] => 4SAP
                              [2] => 0041411943
                          )
                  etc. etc.
                  

                  更新 - 基于答案

                  感谢您的回答.

                  解决方案通常是手动创建 SQL 字符串,并且所有行都可以作为一个插入:

                  The solution would normally be to manually create the SQL-string and all rows can be inserted as one:

                  INSERT INTO `tx_opengate_table` (`machine` ,`customer` ,`type`)
                  VALUES
                    ('m123', 'dfkj45', 'A'),
                    ('m137', 'kfkj49', 'A'), "repeat this line for each entry in the array"
                    ... ... ...
                    ('m654321', '34dgf456', 'C4') "end with out comma, or remove last comma"
                  ;
                  

                  TYPO3专用

                  我碰巧在 CMS TYPO3 中执行此操作,刚刚发现不久前添加的一个新功能:

                  I happen to do this in the CMS TYPO3 and just came across a new function added not that long ago:

                  //Insert new rows
                  $table = 'tx_opengate_stuff';
                  $fields = array('machine','type','customer');
                  $lines = "array as given above"
                  $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows($table,$fields,$lines);
                  

                  推荐答案

                  我会说自己构建它.你可以这样设置:

                  I would say just build it yourself. You can set it up like this:

                  $query = "INSERT INTO x (a,b,c) VALUES ";
                  foreach ($arr as $item) {
                    $query .= "('".$item[0]."','".$item[1]."','".$item[2]."'),";
                  }
                  $query = rtrim($query,",");//remove the extra comma
                  //execute query
                  

                  如果有必要,不要忘记转义引号.

                  Don't forget to escape quotes if it's necessary.

                  另外,请注意不要一次发送太多数据.您可能必须分块执行它,而不是一次全部执行.

                  Also, be careful that there's not too much data being sent at once. You may have to execute it in chunks instead of all at once.

                  这篇关于php+mysql:在mysql中插入一个php数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                      • <bdo id='goqdN'></bdo><ul id='goqdN'></ul>
                          <i id='goqdN'><tr id='goqdN'><dt id='goqdN'><q id='goqdN'><span id='goqdN'><b id='goqdN'><form id='goqdN'><ins id='goqdN'></ins><ul id='goqdN'></ul><sub id='goqdN'></sub></form><legend id='goqdN'></legend><bdo id='goqdN'><pre id='goqdN'><center id='goqdN'></center></pre></bdo></b><th id='goqdN'></th></span></q></dt></tr></i><div id='goqdN'><tfoot id='goqdN'></tfoot><dl id='goqdN'><fieldset id='goqdN'></fieldset></dl></div>
                            <tbody id='goqdN'></tbody>

                        • <legend id='goqdN'><style id='goqdN'><dir id='goqdN'><q id='goqdN'></q></dir></style></legend>

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

                            <tfoot id='goqdN'></tfoot>