我有两个存储过程,我需要将记录(比如选择每个下一个n
记录)分页到第一个选择所有匹配记录的记录。
CREATE PROCEDURE `trans_all`(IN varphone VARCHAR(15))
BEGIN
Select
loans.amt,
loans.date,
loans.pay_period,
borrower.phone As borrower_phone,
borrower.name As borrower_name,
lender.phone As lender_phone,
lender.name As lender_name,
From
loans Left Join
users borrower On borrower.id = loans.borrower_id Left Join
users lender On lender.id = loans.lender_id
Where
(lender.phone = varphone) or (borrower.phone = varphone);
END
然后我得到 php 的计数;像这样
$result = $mysqli->query(sprintf("call trans_all('%s')",$phone));
$num_recs = $result->num_rows;
然后我需要选择精确的记录来执行此操作
$result = $mysqli->query(sprintf("call trans_history('%s','%s','%s')",$phone,$start,$limit));
$row = $result->fetch_assoc(); // this like gives the error Commands out of sync; you can't run this command now
第二个存储过程是
CREATE PROCEDURE `trans_history`(IN varphone VARCHAR(15), IN page INT, IN items INT)
BEGIN
Select
loans.amt,
loans.date,
loans.pay_period,
borrower.phone As borrower_phone,
borrower.name As borrower_name,
lender.phone As lender_phone,
lender.name As lender_name,
From
loans Left Join
users borrower On borrower.id = loans.borrower_id Left Join
users lender On lender.id = loans.lender_id
Where
(lender.phone = varphone) or (borrower.phone = varphone) LIMIT page , items;
END
什么可能导致此错误?