doujing6436 2010-10-27 19:31
浏览 18

立即执行多个插入,更新,以“;”分隔的查询!

I use remote server to store values into MySQL database.

I don't use any SELECT queries, only INSERT, DELETE and UPDATE.

When I execute 70,000 queries I have trouble with speed.

I was trying mysql_unbuffered_query and I saw little performance profit but it's still too slow.

I remember that some functions in PHP allow me to execute several lines, separated by ;

$something=<<<something

query1 ;
query2 ;
query3 ;

something;

execute($something)

Can someone can help me remember ?

Maybe in PDO ?

  • 写回答

6条回答 默认 最新

  • dqingn8836 2010-10-27 19:38
    关注

    The feature you are thinking of is the PHP heredoc syntax. It allows you to do multiple line strings using <<<.

    But PDO does not support multiple SQL statements at once. You need to split them up and execute each one individually. You said this was too slow for you, so you may not be able to use PDO.

    If you have many statements that are the same but with different parameters, you can use PDO prepared statements. With these, you can prepare the statement once, then just execute it with different parameters. If you have multiples types of statements, you will need to prepare each individually. You can read more about prepared statements here. They also have the benefit of not being vulnerable to SQL injection.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line