class Agent extends Model
{
public $Dbname = 'UserDBConn';
public function GetIndirectAgentList($agentId,$strAccount,$strSuperior,$iPageIndex,$pagesize)
{
$conn = $this->Dbconn($this->Dbname);
try{
$TotalCount = 0;
$res = $conn::query('exec [dbo].[Agent_GetAgentList] :agentId,:strAccount,:strSuperior,:iPageIndex,:pagesize,:TotalCount', [
'agentId' => $agentId,
'strAccount' => [$strAccount, PDO::PARAM_STR],
'strSuperior' => [$strSuperior, PDO::PARAM_STR],
'iPageIndex' => [$iPageIndex, PDO::PARAM_INT],
'pagesize' => [$pagesize, PDO::PARAM_INT],
'TotalCount' => [$TotalCount, PDO::PARAM_INPUT_OUTPUT],
]);
}catch (PDOException $e)
{
return false;
}
return $res;
}
}
最初的Agent.php
很显然 这里并不会获取到@AgentID 以及 @TotalCount;他只会返回Agent_GetAgentList的结果集
public function GetIndirectAgentList($agentId,$strAccount,$strSuperior,$iPageIndex,$pagesize)
{
$conn = $this->Dbconn($this->Dbname);
try{
$res = $conn->query('
SET NOCOUNT ON;
declare @AgentID int;
declare @TotalCount int;
exec [dbo].[Agent_GetAgentList] '.$agentId.',\''.$strAccount.'\',\''.$strSuperior.'\','.$iPageIndex.','.$pagesize.',@TotalCount output;
select @AgentID as AgentID,@TotalCount as TotalCount
');
}catch (PDOException $e)
{
return false;
}
return $res;
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持黑区网络。
