I am using two IN and OUT param in store procedure where I am getting two result, I want the two result in PHP -
create procedure `prev1`(in `page` int(50), out `foundrows` int(255)) begin declare foundrows varchar(255); select sql_calc_found_rows * studentmarks limit page ,6; select found_rows()as foundrows; end
this php code
$pag=$_get["offset"]; $sql="call prev1($pag,@foundrows)"; $result = mysqli_query($conn,$sql);
and response is
mysqli_result object ( [current_field] => 0 [field_count] => 13 [lengths] => [num_rows] => 6 [type] => 0 )
but found_rows not getting in php. total found_rows 19 showing [num_rows] => 6
to return value stored procedure:
sql :
delimiter // create procedure prev1(in `page` int, out `out_val` int) begin select sql_calc_found_rows * studentmarks limit page ,6; select found_rows() out_val; end // delimiter ;
php code:
<?php error_reporting(-1); ini_set('display_errors', 'on'); ?> <!doctype html> <html> <body> <?php $servername = "localhost"; $username = "root"; $password = "password"; $dbname = "dbname"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $pag = 1; $conn->multi_query("call prev1($pag,@out_val);select @out_val count"); { /* store first result set */ if ($result = $conn->store_result()) { while ($row = $result->fetch_row()) { print_r($row); } $result->free(); } /* print divider */ if ($conn->more_results()) { printf("-----------------\n"); } } while ($conn->next_result()); ?> </body> </html>
i hope help.
wiki
Comments
Post a Comment