I've done this before in .Net but I am somewhat new to PHP and could use some help. I'm trying to pull data in PHP from a MSSQL db, some of which is Greek letters. The data type of the MSSQL columns is nvarchar and the Greek characters are displayed correctly in management studio; however, whenever I pull the data with the sqlsrv_query function in php I get a bunch of question marks.
In sqlsrv_connect function I've tried setting CharacterSet"=>"UTF-8 which doesn't work.
I've tried iconv(), but am not sure which sets to use.
I tried mb_detect_encoding() and it returned ASCIIASCII.
Here is some sample code:
public function _getOrderItemDetails($orderItemIds,$productTypeId){
$params = explode(',', $orderItemIds);
$sql = "select od.*, ofs.Sort
from orderDetail od
left join orderFieldSort ofs on ofs.fieldName = od.name and productTypeId in ($productTypeId)
where orderItemid in (".rtrim(str_repeat('?,', count($params)),',').")
order by ofs.sort";
return $this->_compileResults($sql,'OrderDetail',$params);;
}
private function _compileResults($sql,$classType,$params ){
$result = sqlsrv_query($this->conn,$sql,$params);
$arrayResult = array();
while($orderObject = sqlsrv_fetch_object($result,$classType)){
array_push($arrayResult, $orderObject);
}
return $arrayResult;
}
Any suggestions are welcome. Please help!
Aucun commentaire:
Enregistrer un commentaire