0
임이 쿼리를 실행
$stmt = $this->dbAdapter->query($query);
$rawResult = $stmt->execute();
가 어떻게 두 번째 결과를 액세스 할 수 있습니까? $rawResult->next()
은 첫 번째 쿼리의 값만 반환합니다.
임이 쿼리를 실행
$stmt = $this->dbAdapter->query($query);
$rawResult = $stmt->execute();
가 어떻게 두 번째 결과를 액세스 할 수 있습니까? $rawResult->next()
은 첫 번째 쿼리의 값만 반환합니다.
두 가지 다른 쿼리를 사용하십시오.
/*
* First Query
*/
$query = "
Select * From table1 Where id = 1
";
$stmt = $this->dbAdapter->query($query);
$rawResult = $stmt->execute();
/*
* Second Query
*/
$query = "
Select * From table2 Where name = 'test'
";
$stmt = $this->dbAdapter->query($query);
$rawResult = $stmt->execute();
두 개의 쿼리가 이런 방식으로 전송되는 방식과 유사하다고 생각됩니다.
코드 중복을 피하기 위해 복제 된 코드를 메서드로 래핑 할 수 있습니다.
$rawResult1 = $this->getResults("Select * From table1 Where id = 1");
$rawResult2 = $this->getResults("Select * From table2 Where name = 'test'");
function getResults(string $query)
{
$stmt = $this->dbAdapter->query($query);
return $stmt->execute();
}
감사합니다. 당신이 나를 도울 수 있습니다 (: http://stackoverflow.com/questions/42859322/zend-2-sqlsrv-prepareparams-not-setted/42884181#42884181). – stefen