Home >Database >phpMyAdmin >How to create a function in a database in phpmyadmin

How to create a function in a database in phpmyadmin

藏色散人
藏色散人forward
2021-06-04 11:49:542963browse

The following tutorial column of phpmyadmin will introduce to you how phpmyadmin creates functions in a database. I hope it will be helpful to friends in need!

How to create a function in a database in phpmyadmin

Create a function in a certain database on phpmyadmin

Changed the PHP project to add a function, and added a function to the local MYSQL function, now we need to transfer it to the server, and then the MYSQL on the server can only be operated through the PHPMYADMIN web page. Enter the statement to create the function in the SQL on the web page.

The result is an error: this function has none of DETERMINISTIC

After checking, this is the reason: https://www.php.cn/mysql-tutorials-477456.html

above Run again: set global log_bin_trust_function_creators=1; That’s it.

My local MYSQL is connected using SQLYOG. If there are comments like /* in the exported function creation statement, put It needs to be removed when executing on PHPMYADMIN, otherwise it may not be executed, and

DEFINER=`root`@`%` also needs to be removed. . .

The following is my function creation statement:

USE `sql88_aosijue_c`;
DELIMITER $$
CREATE FUNCTION `calc_xjs`(user_id int) RETURNS int(11)
BEGIN 
return (SELECT COUNT(1) FROM tp_users WHERE pid=user_id);
END  $$
DELIMITER ;

Note that if PHPMYADMIN placed on the server is executed, the database name after USE must be consistent with the one on the server.

The above is the detailed content of How to create a function in a database in phpmyadmin. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete