* fix a bug for search with product.

This commit is contained in:
wangyidong
2013-03-14 09:29:21 +00:00
parent 93e4430596
commit 27e1603f68
2 changed files with 20 additions and 3 deletions
+12 -2
View File
@@ -113,10 +113,20 @@ class testcase extends control
if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1');
}
$caseQuery = str_replace("`product` = 'all'", '1', $this->session->testcaseQuery); // If product is all, change it to 1=1.
$queryProductID = $productID;
$allProduct = "`product` = 'all'";
$caseQuery = $this->session->testcaseQuery;
if(strpos($this->session->testcaseQuery, $allProduct) !== false)
{
$products = array_keys($this->loadModel('product')->getPrivProducts());
$caseQuery = str_replace($allProduct, '1', $this->session->testcaseQuery);
$caseQuery = $caseQuery . ' AND `product`' . helper::dbIN(array_keys($products));
$queryProductID = 'all';
}
$caseQuery = $this->loadModel('search')->replaceDynamic($caseQuery);
$this->view->cases = $this->dao->select('*')->from(TABLE_CASE)->where($caseQuery)
->andWhere('product')->eq($productID)
->beginIF($queryProductID != 'all')->andWhere('product')->eq($productID)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}