Best practice forum (Archived)

Help with calling stored procedures!

 
John Unnever
Help with calling stored procedures!
de John Unnever - Wednesday, 26 de October de 2016, 16:53
Grupo Partners

Hello there!  Looking for someone who has some experience in the moodle data api and how to call / retrieve data from stored procedures.  I haven't been able to find it being done in any of the totara/moodle code yet.

This below query works as is.. but is not using the moodle data api ... i'd like to convert it to use the API but am struggling!  Does anyone have any idea how this would look converted to the API ?

 

Looking for a pro at using the moodle data api for some help converting this query!  Right now this query works as is.. but i'm struggling to get it converted to using the data API.   Anyone have any ideas?  It is calling stored procedures to get data back... i haven't seen this done in any other moodle code.

 

$sql= "CALL di_get_PartA_dates('$appraisalid','$userid','A-1',@em_a1,@ra_a1,@re_a1)";

$result = $conn->query($sql);

if (!($result = $conn->query("SELECT @em_a1, @ra_a1, @re_a1"))) {
echo "SELECT failed: (" . $conn->errno . ") " . $conn->error;
}
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()){
$a1EmpDate = $row['@em_a1'];
$a1RatDate = $row['@ra_a1'];
$a1RevDate = $row['@re_a1'];
}
}