public function exec($sql, $dbconfig, $unicode = 'gb2312') { $dao = new Dao('', 'jk_dnb_hgk_send', '', false, $dbconfig); $sql = $this->auto_charset($sql, 'utf8', $unicode); if (strpos($sql, 'select') !== false) { $result = $dao->query($sql)->toArray(); if ($result) { $result = $this->auto_charset($result, $unicode, 'utf8'); for ($i = 0; $i < count($result); $i++) { for ($j = count($result[$i]); $j >= 0; $j--) { unset($result[$i][$j]); } } $rtn["result"] = true; $rtn["value"] = $result; } else { $rtn["result"] = false; } } else { $result = $dao->execute($sql); if ($result) { $rtn["result"] = true; $rtn["value"] = $result; } else { $rtn["result"] = false; } } return $rtn; }
/** * 输出出仓数据 * * @param $data */ public function outPut($data, $dbconfig) { //无条码不用做 if (!$data["code"]) { return true; } $unicode = $dbconfig['unicode']; if (!$unicode) { $unicode = 'gb2312'; } $billtypedao = new BilltypeDao(); $billtype = $data["billType"]; $result = $billtypedao->find("billtypeDesc='{$billtype}'"); $result = $result->toArray(); if ($result["stype"] != 'OUT') { return true; } $dao = new Dao('', 'jk_dnb_hgk_send', '', false, $dbconfig); $dao->startTrans(); try { if ($data["memo"] == '电能表') { $sql = "insert into jk_dnb_hgk_recieve (fc_tm) values('" . $data["code"] . "')"; } else { $sql = "insert into jk_hgq_hgk_recieve (fc_tm) values('" . $data["code"] . "')"; } $sql = $this->auto_charset($sql, 'utf8', $unicode); $result = $dao->execute($sql); } catch (Exception $e) { $dao->rollback(); throw new Exception($e); } $dao->commit(); return true; }