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

如何從 PHP 在 mySQL 中插入/創建存儲過程?

How to insert/create stored procedures in mySQL from PHP?(如何從 PHP 在 mySQL 中插入/創建存儲過程?)
本文介紹了如何從 PHP 在 mySQL 中插入/創建存儲過程?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有許多用 MySQL Workbench 制作的存儲過程.當使用 MySQL 工作臺將它們放入我的測試數據庫時,它們工作得很好.

I've got a number of stored procedures made with the MySQL Workbench. They work just fine when use MySQL workbench to put them into my test DB.

現在我正在準備用于部署的數據庫創建腳本,這是唯一給我帶來麻煩的腳本.當我使用命令行/mysql shell 時,該腳本運行良好.只有當我使用 PHP mysql(i) 接口來執行腳本時,它才會失敗.不做評論.

Now I am preparing the DB creation scripts for deployment, and this is the only one giving me trouble. When I use the command line / mysql shell, the script works perfectly well to. It's only when I use the PHP mysql(i) interface to execute the script - it fails. Without comment.

我使用 MySQL 工作臺為我生成的過程創建腳本;也就是說,它有這個模式:

I use the procedure creation scripts as MySQL workbench generates for me; that is, it has this pattern:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

在腳本開始處,然后對每個過程重復:

at the start of the script, then repeating for each procedure:

DELIMITER $$
USE `dbname`$$
CREATE PROCEDURE `procname`(IN inputparameters)
BEGIN

...程序在這里

;
END$$
DELIMITER ;

如果從 MySQL Workbench 運行,這個腳本可以正常工作.如果我從 mysql 命令行嘗試相同的操作,它也可以正常運行.但是當我通過 PHP mysqli 接口執行它時它無法完成任何事情(使用 mysqli_multi_query 執行它,這對于創建和填充數據庫的其他腳本工作正常).界面上沒有返回錯誤,沒有結果(!).我得到的只是假",僅此而已.錯誤代碼為 0,沒有錯誤信息.

This script works fine if run from MySQL Workbench. It also runs fine if I try the same from mysql commandline. But it fails to accomplish anything when I execute it through the PHP mysqli interface ( executing it with mysqli_multi_query, which works fine for the other scripts creating and populating the DB). There is no error returned on the interface, no results (!). All I get is "false", and that's it. error code is at 0, no error message.

這對我來說是一個很大的 WTF,我希望你能指出我正確的方向 - 我該如何解決這個問題并從 PHP 安裝程序?

It's a big WTF for me, and I hope you can point me in the right direction - how can I fix this and install the procedures from PHP?

PS:授予并驗證了 root/admin 訪問權限(畢竟,我剛剛創建了具有相同連接、創建用戶、插入表等的數據庫).

PS: root/admin access is given and verified (after all, I just created the DB with the very same connection, created users, inserted tables and so on).

推薦答案

總結一下:

DELIMITER 是在客戶端實現的,而不是服務器端.

DELIMITER is implemented client-side, not serverside.

如果你有一個好的驅動程序或 API,它可能會解決這個問題.PHP mysql/mysqli,截至目前,沒有.

If you have a good driver or API, it may take care of this. PHP mysql / mysqli, as of now, do not.

如果您需要使用不同的分隔符(例如,因為默認分隔符出現在腳本中),您必須自己編碼/轉義 SQL 或將其分解,這樣您就不需要更改分隔符.此處沒有 PHP 的幫助.

If you need to use a different delimiter (e.g. because the default delimiter appears inside scripts), you have to encode/escape your SQL yourself or break it up so you don't need to change the delimiter. No help from PHP here.

這篇關于如何從 PHP 在 mySQL 中插入/創建存儲過程?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 日韩欧美国产一区二区 | 国产乱精品一区二区三区 | 在线成人| 色橹橹欧美在线观看视频高清 | 免费小视频在线观看 | 国产精品毛片一区二区在线看 | 亚洲午夜视频 | 亚洲 欧美 另类 综合 偷拍 | 成人一区精品 | 色视频欧美 | 精品久久久久久亚洲国产800 | 九九av| 丁香久久 | 玖玖免费 | 99精品免费视频 | 亚洲字幕在线观看 | 国产丝袜一区二区三区免费视频 | 国产日韩av一区二区 | 久久99国产精一区二区三区 | 亚洲社区在线 | 亚洲草草视频 | 波多野结衣在线观看一区二区三区 | 免费特黄视频 | 久久久久久久久久久久久9999 | 毛片a级| 99九九视频| 国产剧情一区 | 精品国产乱码久久久久久果冻传媒 | 久草免费在线视频 | 夜夜av| 国产高清精品一区二区三区 | 黄色精品 | 亚洲综合大片69999 | 久久久久国产一区二区三区 | 久久久久久国产一区二区三区 | 久久四虎| 欧美日韩国产一区二区三区 | 国产精品成人一区二区三区夜夜夜 | 成年人在线观看视频 | 午夜国产精品视频 | 国产精品中文字幕在线 |