English 中文(简体)
如何执行我的指挥
原标题:how to execute mysql command DELIMITER
  • 时间:2011-03-15 07:11:35
  •  标签:
  • php
  • mysql

I have huge problem (for me)

我需要执行PHP的MySQL指令DELIMITER <>code>,但mysql_query(有误。 我发现,mysql_query(>n t support the use of DEMITER,因为这一指挥只在MySQL console工作。

但是,当我打开了phpMyAdmin时,可以选择将DELIMITER改变在Kingk及其运作,但我不知道如何。

Is it possible to change delimiter from PHP? I need it to do before calling a CREATE TRIGGER command that uses several ;.

问题回答

也许,don t需要修改定义。

限制在CLCS中是必需的,以便了解KQ号声明的结尾之处,因为CLI将不断阅读和执行更多的声明,直到你告诉它停止(例如,有exit或控制-D)。 但是,它实际上的行文只是个性流;它需要说明一个声明何时结束和下一个开始。 这符合定义者所做的。

In PHP, each function call executes one statement. There can t be multiple statements in one function call, so there is no need for a way to delimit them. The statement is the entire string. This is true of the old mysql_query as well as the newer mysqli_query and PDO. Of course, there is mysqli_multi_query if you really want to pass multiple queries to one function.

在存储程序/触发/功能/etc的情况下,可以有多种说明,但由MySQL自己处理(总有<代码>;,AFAIK)。 就购买力平价而言,这仍然是一份声明。

限制你在phpMyAdmin看到的情况,可能被用来分裂发言,而且很可能在《公共卫生法》中这样做。 它必须这样做,因为它接受用户的投入,包括多种发言,但只能通过每个职能电话一次发言。 (我已经检查了《加拿大刑法》,以完全确保这一点。)

It depends. I use MySQLi s multi_query() function and leave ; as is when doing a procedure creating, actually done (PHP 5.6 & MySQL 5.6). I think you do not need care delimiter, leave the target code only then might work. You might try to query SQL only as

CREATE XXXX
BEGIN
    sth;
END

也有尝试。

you need a stored routine (procedure, function) to include all the necessary queries,
so in PHP, you can call the stored routine elegantly





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签