How to write a stored procedure in phpMyAdmin?
In phpMyAdmin you can create the stored procedure in the SQL window.
You may have to set the delimieter to something like "$$" instead of the default ";". You can change this from the bottom of the SQL window.
Also you can refer this: http://www.mysqltutorial.org/mysql-stored-procedure-tutorial.aspx
How do I view my stored procedures in phpMyAdmin?
View stored procedures in phpmyadmin:
Query:
SELECT routine_definition
FROM information_schema.routines
WHERE
routine_name = 'procedure_name' AND routine_schema = 'databasename';
Here's how to get there in phpmyadmin.
The routines
option is available in phpmyadmin
. The link is not visible in PHPmyadmin until you have at least one stored procedure. See the above image and click the routines
link under structure
tab.
How to write a stored procedure using phpmyadmin and how to use it through php?
Since a stored procedure is created, altered and dropped using queries you actually CAN manage them using phpMyAdmin.
To create a stored procedure, you can use the following (change as necessary) :
CREATE PROCEDURE sp_test()
BEGIN
SELECT 'Number of records: ', count(*) from test;
END//
And make sure you set the "Delimiter" field on the SQL tab to //.
Once you created the stored procedure it will appear in the Routines fieldset below your tables (in the Structure tab), and you can easily change/drop it.
To use the stored procedure from PHP you have to execute a CALL query, just like you would do in plain SQL.
Stored Procedure in mysql phpmyadmin #1064
MySQL IF-clause uses THEN
END IF
instead of BEGIN
and END
.
You also might want to use temporary table for the IDBillInfoTable
so it works with concurrent use.
IF (idSecondBill IS NULL) THEN
INSERT INTO bill (id_table, bill_maker, status)
VALUES (idTable2, 1, 0);
SELECT MAX(id) into idSecondBill
FROM bill
WHERE id_table = idTable2 AND status = 0;
END IF;
and temporary table creation:
CREATE TEMPORARY TABLE IDBillInfoTable AS
SELECT id
FROM bill_info
WHERE id_bill = idSecondBill;
and dropping the temp table
DROP TEMPORARY TABLE IDBillInfoTable;
Related Topics
Verify Imagemagick Installation
Convert Utc Dates to Local Time in PHP
How to Get the Unicode Value of a Character or Vise Versa with PHP
How to Get Previous Month and Year Relative to Today, Using Strtotime and Date
How to Make PHP Generate Chunked Response
Why Does Tcpdf Ignore My Inline CSS
How to Call the Constructor with Call_User_Func_Array in PHP
Php/Regex: How to Get the String Value of HTML Tag
Any Way to Specify Optional Parameter Values in PHP
Rerouting All PHP Requests Through Index.Php
How to Include Authorization Header in Curl Post Http Request in PHP
Exotic Names for Methods, Constants, Variables and Fields - Bug or Feature
How to Can Post a Multiple Photos via Facebook API
Extracting All Values Between Curly Braces Regex PHP
Is PHP Str_Word_Count() Multibyte Safe