How to call sqlserver's paging stored procedure in php
孤独岛
孤独岛 2021-11-05 13:52:01
0
2
667

How to call the paging stored procedure with return value when php connects to sqlserver using PDO method?

ALTER PROC [dbo].[sp_PageView]

@tbname varchar(128), --The name of the table to be displayed in pages

@FieldKey varchar(1000), - -The main key (unique) field for positioning records can be a comma separated multiple fields

#@PageCurrent Int = 1, -The page number to be displayed

@PageSize int = 10 10 , -The size of each page (record number)

@Fieldshow varchar (1000) = '', -the field list to be displayed in a comma, if not specified, display all fields

@FieldOrder varchar(1000)='', --Comma-separated list of sorting fields, you can specify DESC/ASC after the field

-- Used to specify the sorting order

@Where varchar(1000)='', --Query condition

@RecordCount Int Output, --Total number of records

@PageCount int OUTPUT --Total number of pages

The above are the parameter settings of the stored procedure

$stmt = $conn->prepare("EXEC $procName ?, ?, ?, ?, ?, ?, ?,?,?");$stmt ->bindParam(1, $tablename, PDO::PARAM_STR );$stmt->bindParam(2, $FieldKey, PDO::PARAM_INT );$stmt->bindParam(3, $Pagecurrent, PDO::PARAM_INT );$stmt->bindParam(4, $Pagesize, PDO::PARAM_INT );$stmt->bindParam(5, $FieldShow, PDO::PARAM_STR );$stmt->bindParam(6, $FieldOrder, PDO::PARAM_STR );$stmt->bindParam(7, $Where, PDO::PARAM_STR );$stmt->bindParam(8, $recordcount, PDO::PARAM_INT | PDO::PARAM_INPUT_OUTPUT, 4);$ stmt->bindParam(9, $PageCount, PDO::PARAM_INT | PDO::PARAM_INPUT_OUTPUT, 4);

$stmt->execute();

$row = $stmt ->fetchAll(PDO::FETCH_ASSOC);echo json_encode($row,JSON_UNESCAPED_UNICODE);print "";

echo $PageCount;After running, the final total number of pages in the record set is displayed as 0.

###
孤独岛
孤独岛

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!