此页面加载时间过长

时间:2014-09-10 18:34:15

标签: php zend-framework

我在php zend框架上创建了一个视图页面。查看页面有10种方法。每个方法都有3个sql查询返回值。我称这10种方法10次。所有查询都在24,000行的表上工作。加载视图页面需要2-3分钟。我将函数结果存储在数组中并使用数组值进行显示。

如何在此实现输出缓存?

我的观点部分的源代码是: 这些是我的变数:

$no_of_customers = array();
$no_of_customers_EE = array();
$no_of_customers_NEE = array();
$unique_customers = array();
$unique_customers_EE = array();
$unique_customers_NEE = array();
$no_of_sent = array();
$no_of_sent_EE = array();
$no_of_sent_NEE = array();
$no_of_opened = array();
$no_of_opened_EE = array();
$no_of_opened_NEE = array();
$no_of_surveys = array();
$no_of_surveys_EE = array();
$no_of_surveys_NEE = array();   
$promoter = array();
$promoter_EE = array();
$promoter_NEE = array();
$detractor = array();
$detractor_EE = array();
$detractor_NEE = array();
$passive = array();
$passive_EE = array();
$passive_NEE = array();

我正在使用的功能之一是

function unique_customer($con,$start_date,$end_date ,&$unique_customers,$i,$customerTable,&$unique_customers_EE,&$unique_customers_NEE)
{

$result = mysqli_query($con,"SELECT COUNT(DISTINCT emailAddress) AS Total, product FROM $customerTable  WHERE importDate >='$start_date' AND importDate <'$end_date' ;");
$rs = mysqli_fetch_array($result);

$unique_customers[$i] = $rs['Total'];
unset($rs);

$result_EE = mysqli_query($con,"SELECT COUNT(DISTINCT emailAddress) AS Total_EE, product FROM $customerTable  WHERE importDate >='$start_date' AND importDate <'$end_date' AND product = '';");
$rs_EE = mysqli_fetch_array($result_EE);

$unique_customers_EE[$i] = $rs_EE['Total_EE'];
unset($rs_EE);

$result_NEE = mysqli_query($con,"SELECT COUNT(DISTINCT emailAddress) AS Total_NEE, product FROM $customerTable  WHERE importDate >='$start_date' AND importDate <'$end_date' AND product != '';");
$rs_NEE = mysqli_fetch_array($result_NEE);

$unique_customers_NEE[$i] = $rs_NEE['Total_NEE'];
unset($rs_NEE);

}

调用这些函数10次并将值存储在数组中

0 个答案:

没有答案