次のコードを使用して、mssqlデータベースからいくつかのデータを取得したいと思います。
public function areaGetCities($json){
$request = json_decode($json);
$response = '';
$response->list = array();
if (!empty($request->language_id) &&
!empty($request->country_id) &&
!empty($request->postal_code)){
$this->db_stmt = new PDOStatement();
$this->db_stmt = $this->db->prepare('EXECUTE areaGetCities :language_id, :country_id, :postal_code');
$this->db_stmt->bindParam(':language_id', $request->language_id, PDO::PARAM_INT);
$this->db_stmt->bindParam(':country_id', $request->country_id, PDO::PARAM_INT);
$this->db_stmt->bindParam(':postal_code', $request->postal_code, PDO::PARAM_STR, 40);
$this->db_stmt->execute();
while ($obj = $this->db_stmt->fetchObject()){
$response->list[] = $obj;
unset($obj);
}
}
return json_encode($response);
}
errorInfo()を出力すると、
パラメータ番号0をバインドしようとしました。SQLServerは最大2100個のパラメータをサポートします。IMSSP -29
私の問題は、データベースから結果が得られず、取得する必要があることです(同じパラメーターを使用してプロシージャを実行し、2つの結果を取得します)。
アイデア?
編集:コードを編集しました。今私は得る:
[Microsoft] [SQL Server Native Client 11.0] [SQLServer]仮パラメーター"@postal_code">はOUTPUTパラメーターとして宣言されていませんが、要求された出力で渡される実際のパラメーターです。
CREATE PROCEDURE areaGetCities(@language_id TINYINT, @country_id INT, @postal_code VARCHAR(40))