• <tfoot id='PLcKS'></tfoot>

    1. <small id='PLcKS'></small><noframes id='PLcKS'>

        <bdo id='PLcKS'></bdo><ul id='PLcKS'></ul>
    2. <legend id='PLcKS'><style id='PLcKS'><dir id='PLcKS'><q id='PLcKS'></q></dir></style></legend>

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

      1. 在 PHP 中使用 PDO 创建存储过程

        时间:2023-10-04
      2. <small id='0GP1Q'></small><noframes id='0GP1Q'>

          <tbody id='0GP1Q'></tbody>

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

                  <tfoot id='0GP1Q'></tfoot>
                  <legend id='0GP1Q'><style id='0GP1Q'><dir id='0GP1Q'><q id='0GP1Q'></q></dir></style></legend>
                  本文介绍了在 PHP 中使用 PDO 创建存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在从 PHP 读取 TEXT 文件并尝试从中执行命令,例如创建数据库及其拥有的所有表和过程.我的代码创建了表,但没有创建文件中给出的存储过程.

                  I am reading a TEXT file from PHP and trying to execute commands from it, like creating a DB and all the tables and procedures it has. My code creates the tables but does not create Stored Procedures given in the file.

                   DELIMITER $$
                   DROP PROCEDURE IF EXISTS `add_hits`$$
                   CREATE DEFINER=`root`@`localhost` PROCEDURE `add_hits`( In id varchar(255))
                   BEGIN
                   select hits into @hits from db_books where Book_ID = id;
                   update db_books set hits=@hits+1 where Book_ID = id;
                   END$$
                  

                  PDO 没有创建 SP,如何才能完成这项任务?我已经尝试将所有代码部分一起并逐行执行,但没有任何效果.
                  我正在尝试制作数据库安装程序脚本.

                  The PDO is not creating the SPs, how will be able to accomplish this task? I have tried executing all the code part together and line by line, but nothing works.
                  I am trying to make a DB installer script.

                  推荐答案

                  好吧,PMA 帮我回答了我自己的这个问题.
                  为了克服这个问题,您需要删除程序的分隔符部分,以便您的查询变成:

                  Well, PMA Helped me with answering this Question of my own.
                  To overcome this you need to remove the delimiter part of the procedure, so that your queries become like:

                   DROP PROCEDURE IF EXISTS `add_hits`;
                   CREATE DEFINER=`root`@`localhost` PROCEDURE `add_hits`( In id varchar(255))
                   BEGIN
                   declare hits_bk int;
                   select hits into hits_bk from db_books where Book_ID = id;
                   update db_books set hits=hits_bk+1 where Book_ID = id;
                   END;
                  

                  现在查询将起作用.
                  感谢@Your Common Sense 和@RiggsFolly 的帮助.

                  Now the queries will work.
                  Thanks to @Your Common Sense and @RiggsFolly for helping out.

                  这篇关于在 PHP 中使用 PDO 创建存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP PDO 异常:找不到驱动程序 下一篇:如何使用 PDO 和 memcached 设计缓存系统?

                  相关文章

                  最新文章

                    <tfoot id='EqtO8'></tfoot>

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

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

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