/** * 建立表的索引 * * @param Date $date * @param String $tablename * @return boolean * @author kenlnog.zhang */ private static function createTableIndex($date, $tablename) { try { $dao = new StocksIndexDao(); $vo = new StocksIndexVo(); $y = substr($date, 0, 4); $m = substr($date, 5, 2); $sdate = strtotime("{$y}-{$m}-1"); // 该月开始 $edate = strtotime("{$y}-{$m}-" . date("t", $sdate)); //该月结束 $vo->begindate = date('Y-m-d', $sdate); $vo->enddate = date('Y-m-d', $edate); $vo->tablename = $tablename; $dao->add($vo); $dao->commit(); return true; } catch (Exception $e) { throw new Exception($e); } }
/** * 清理数据 * * @param array $cleardata 要清理的类型 */ public function clear($cleardata) { if (!is_array($cleardata)) { return "数据清理失败"; } try { for ($i = 0; $i < sizeof($cleardata); $i++) { $datatype = $cleardata[$i]; switch ($datatype) { case '采购申请': $dao = new PurchaseOrderHeadDao(); $dao->deleteAll(''); $dao = new PurchaseOrderDetailDao(); $dao->deleteAll(''); break; case '客户资料': $dao = new ClientsDao(); $dao->deleteAll(''); break; case '故障登记': $dao = new FaultLogsDao(); $dao->deleteAll(''); break; case '定期检查': $dao = new CheckLogsDao(); $dao->deleteAll(''); break; case '投诉登记': $dao = new ComplaintLogsDao(); $dao->deleteAll(''); break; case '产品资料': $dao = new GoodsDao(); $dao->deleteAll(''); break; case '厂商资料': $dao = new SupplyDao(); $dao->deleteAll(''); break; case '库房资料': $dao = new StorageDao(); $dao->deleteAll(''); break; case '库存资料': $dao = new StocksIndexDao(); $result = $dao->findAll()->toResultSet(); for ($j = 0; $j < sizeof($result); $j++) { $tablename = $result[$j]['tablename']; $dao->deleteAll('', $tablename); } $dao->deleteAll('', 'stc_currentstocks'); $dao->deleteAll('', 'stc_codeIndex'); break; case '条码规则': $dao = new CodeDictDao(); $dao->deleteAll(''); break; case '开灯记录': $dao = new UnconfirmstationDao(); $dao->deleteAll(''); break; } } } catch (Exception $e) { throw new Exception($e); } return true; }