环境是跑在虚拟机上的64位Windows Server 2008+wampserver2.5
数据库是Oracle
代码如下
<?php
namespace Home\Controller;
use Think\Controller;
class TestController extends Controller {
public function test($search5_idcard='',$search5_yshtbh='',$search5_htbh=''){
G('begin');
/*
if($search5_yshtbh){
$Data = M('kfs_db a,kfs_syqfw b,kfs_syq c','','DB_CONFIG5');
$condition='b.ywzh = c.ywzh and b.clh = a.yc_clh and c.zxbz = 0 and c.HTBH = \''.$search5_yshtbh.'\' and c.qlrzjhm = \''.$search5_idcard.'\'';
}else{
$Data = M('kfs_db a,kfs_syqfw b,kfs_syq c,kfs_dfzxxb d','','DB_CONFIG5');
$condition='b.ywzh = c.ywzh and c.yszh = d.yszh and d.zxbz = 0 and a.yc_clh = d.yc_clh and c.zxbz = 0 and c.htbh = \''.$search5_htbh.'\' and c.qlrzjhm = \''.$search5_idcard.'\'';
}
//$condition1['b.qlrzjhmmc&b.qlrzjhm&b.qzhm'] =array('xx','xxx','xxxx','_multi'=>true);
$redata = $Data->where($condition)->field('a.zlms,b.sh,b.hsmj,c.qlrmc,c.qdrq')->find();
if($redata==''){
$redata['NUMROW']=0;
}
*/
$Data = M('','','DB_CONFIG5');
$a=$Data->query("select a.zlms, b.sh, b.hsmj, c.qlrmc, c.qdrq from kfs_db a, kfs_syqfw b, kfs_syq c where b.ywzh = c.ywzh and b.clh = a.yc_clh and c.zxbz = 0 and c.HTBH = '".$search5_yshtbh."' and c.qlrzjhm = '".$search5_idcard."'");
print_r($a);
echo '<br>';
//$redata['ZLMS']=iconv('GBK', 'UTF-8//IGNORE', $redata['ZLMS']);
//$redata['QLRMC']=iconv('GBK', 'UTF-8//IGNORE', $redata['QLRMC']);
G('end');
echo G('begin','end',12).'s<br>';
echo G('begin','end','m').'kb';
die();
$this->ajaxReturn($redata,'JSON');
}
}不使用Thinkphp测试了一下,执行速度基本保持在0.07-0.09秒,但是不再出现之前突然飙升到19秒的情况,代码如下$t1 = microtime(true);
$userName ='xxxx';
$user_pass ='xxxxx';
$conn = oci_connect($userName, $user_pass,'(DESCRIPTION =(ADDRESS_LIST=(ADDRESS =(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521)))(CONNECT_DATA =(SERVICE_NAME = xxxxxx)))');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stmt = oci_parse($conn, "select a.zlms, b.sh, b.hsmj, c.qlrmc, c.qdrq from kfs_db a, kfs_syqfw b, kfs_syq c where b.ywzh = c.ywzh and b.clh = a.yc_clh and c.zxbz = 0 and c.HTBH = '".$search5_yshtbh."' and c.qlrzjhm = '".$search5_idcard."'");
oci_execute($stmt, OCI_DEFAULT);
while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
print_r($row);
//echo " " . oci_result($stmt, "TEST") . "<br>\n";
}
$t2 = microtime(true);
echo '<br>耗时'.round($t2-$t1,12).'秒';以上两段代码都在本机和网络测试过,使用了Thinkphp的代码偶尔出现超长执行时间的情况,没使用Thinkphp的没有该现象发生 最佳答案