Home  >  Article  >  Backend Development  >  同一条sql,php程序执行的结果跟数据库执行的结果不一样,求解

同一条sql,php程序执行的结果跟数据库执行的结果不一样,求解

WBOY
WBOYOriginal
2016-06-13 11:54:321027browse

同一条sql,php程序执行的结果和数据库执行的结果不一样,求解
输出sql和结果集的代码如下

$sql=$sql1.$sql_initbest;<br />echo $sql;<br />//initRows4($start_date,$end_date,$objActSheet);<br /><br />//$months=getIntMonth($start_date,$end_date1);<br />//$count_1=3*$months+3;//每个月有3列<br />//echo $sql1.$sql_initbest;<br />$query = mssql_query($sql);<br />//$c=0;<br />//$arr=Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');<br />//$count_4=0;//月份计数器<br />//$n=4;<br />//$arr1=array();<br />while($row=mssql_fetch_array($query)){<br />	print_r($row);<br />	echo "<br><br>";

输出结果 注意红框中的数据

把sql复制到数据库中执行结果如下

我确定是同一条sql,请问为什么会这样?
------解决方案--------------------
不要用 number_format 函数格式化数据
而应该用单元格格式来控制,比如
$sheet->getStyle('D6')<br />            ->getNumberFormat()<br />            ->setFormatCode('#,##0');<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn