Add information via stored procedure and PHP?

I have a form that contains many elements, my DB guy created SP, and now I need to call this stored procedure. My form has twenty elements, when I click on submit, the data must be stored in the database. I know how to do this when inserting a request, but how to call SP and perform this operation.

There are 10 tables where the data will be saved.

+3
source share
3 answers

I have never used stored procedures in MySQL, but this is no different from “simple” SQL queries, except that you use it CALLas a query keyword.

Instead:

INSERT INTO table (column1, column2, column3) VALUES ('value 1', 'value 2', 3)

:

CALL function_name('value 1', 'value 2', 3);

(, function_name 2 .

+4

PDO . " SQL".

<?php
// Calling a stored procedure with an output parameter
$stmt = $dbh->prepare("CALL sp_returns_string(?)");
$stmt->bindParam(1, $return_value, PDO::PARAM_STR, 4000); 

// call the stored procedure
$stmt->execute();

print "procedure returned $return_value\n";
?>
+1

Source: https://habr.com/ru/post/1738638/


All Articles