Create procedure
delimiter $$
create procedure getLoginIds()
begin
select loginid from user order by id desc limit 100;
end$$
delimiter $$
create procedure getLatestSchedules()
begin
select * from tschedules where active=1 order by id desc limit 100;
end$$
<?php
$con=new mysqli('dev.host.com','uname','pwd','db');
if(mysqli_connect_errno()){
die("Failed to connect");
}
$sql='call getLoginIds()';
$result=$con->query($sql);
if(!$result){
die("failed");
}
//$result=$result1->fetch_assoc();
while($row=$result->fetch_row()){
echo $row[0]."<br>";
}
$result->free();
cleanSP($con);
//calling second sp
$sql='call getLatestSchedules()';
$result=$con->query($sql);
if(mysqli_connect_errno()){
die("Failed to connect");
}
while($row=$result->fetch_row()){
echo $row[0]."<br>";
}
cleanSP($con);
//cleans the result set in the connection
function cleanSP($con){
while($con->next_result()){
}
}
?>
No comments:
Post a Comment