/** * db 处理统一接口 */ public function execute($sql = '', $type = 's') { $res['status'] = 1; $dbRes = false; switch ($type) { //select case 's': $dbRes = mysqli_query($this->conn, $sql); $data = $this->fetch_all_result($dbRes, 1); $res['data'] = $data[0]; break; //insert //insert case 'i': $dbRes = mysqli_query($this->conn, $sql); $res['id'] = mysqli_insert_id($this->conn); break; //update //update case 'u': $dbRes = mysqli_query($this->conn, $sql); break; //delete //delete case 'd': $dbRes = mysqli_query($this->conn, $sql); break; default: # code... break; } if ($dbRes == true) { $res['status'] = 0; } Doo::logger()->info('time:' . date("Y-m-d H:i:s", time()) . "\tip:" . getIP() . "\tsql:" . $sql . "\t" . var_export($res['status'], true), 'DB'); return $res; }
function get_new_movie_by_category($cat, $search = "", $start = 0, $limit = 20) { $cache_name = 'get_new_movie_by_category_' . $cat . $search; $qsearch = ""; if ($search) { $qsearch = " AND ( ov.vod_name like '{$search}%' OR ov.vod_name like '%{$search}%' OR ov.vod_name like '%{$search}' ) "; } /* $query = "SELECT * FROM tv_category_item tci LEFT JOIN tv_program tp ON (tci.content_code = tp.code) LEFT JOIN tv_video tv ON (tci.content_code = tv.content_code) WHERE tci.category_code = '{$cat}' AND tci.visible_status = 0 {$qsearch} ORDER BY tci.insert_time DESC"; */ $query = "SELECT ov.*, ovrc.*, ovc.*, ov.id as vod_id FROM {$this->db_ottmobile}.ott_vod ov \n\t\t\t\t INNER JOIN {$this->db_ottmobile}.ott_vod_relation_category ovrc ON (ov.id = ovrc.vod_id)\n\t\t\t\t INNER JOIN {$this->db_ottmobile}.ott_vod_category ovc ON (ovrc.vod_category_id = ovc.id )\n\t\t\t\t WHERE ovc.vod_category_code ='{$cat}' and ovc.vod_category_status='publish' and ov.vod_status='publish' GROUP BY ov.id ORDER BY episode_group asc, vod_name asc\n\t\t\t\t LIMIT {$start}, {$limit}"; //echo $query; try { //$rs = $this->cache->get($cache_name); //if(!$rs || $this->clearcache){ $rs = $this->dbMobile()->fetchAll($query); // $this->cache->set($cache_name,$rs,$this->cache_time); //} } catch (Exception $e) { Doo::logger()->alert($e); Doo::logger()->writeLogs("log" + date('Y-m-d') + ".txt", false); } return $rs; }
function getRegion() { $query = "SELECT region_code, region FROM ott_geoip_region WHERE country_code ='ID'"; try { $rs = $this->dbMobile()->fetchAll($query); } catch (Exception $e) { Doo::logger()->alert($e); Doo::logger()->writeLogs("log" + date('Y-m-d') + ".txt", false); } return $rs; }
include '../protected/config/common.conf.php'; include '../protected/config/routes.default.conf.php'; include '../protected/config/db.default.conf.php'; include '../protected/config/timezone.conf.php'; include '../protected/config/area.conf.php'; include '../protected/module/default/class/func.php'; // 旧方法库 #Just include this for production mode //include $config['BASE_PATH'].'deployment/deploy.php'; include $config['BASE_PATH'] . 'Doo.php'; include $config['BASE_PATH'] . 'app/DooConfig.php'; # Uncomment for auto loading the framework classes. //spl_autoload_register('Doo::autoload'); Doo::conf()->set($config); # remove this if you wish to see the normal PHP error view. include $config['BASE_PATH'] . 'diagnostic/debug.php'; # database usage //Doo::useDbReplicate(); #for db replication master-slave usage //Doo::db()->setMap($dbmap); Doo::conf()->add('dbconfig', $dbconfig); Doo::loadClassAt('DBproxy', 'default'); // Doo::db()->setDb($dbconfig, $config['APP_MODE']); // Doo::db()->sql_tracking = true; #for debugging/profiling purpose Doo::app()->route = $route; # Uncomment for DB profiling //Doo::logger()->beginDbProfile('doowebsite'); Doo::app()->run(); //Doo::logger()->endDbProfile('doowebsite'); Doo::logger()->rotateFile(102400); Doo::logger()->writeLogs('framework/' . date('Ym') . '/' . date('d') . '.log', false);
function get_spincard($fld = '', $whered = '', $startd = '', $limitd = '') { $cache_name = "get_spincard_{$fld}_{$whered}_{$startd}_{$limitd}"; $rs = false; $where = ''; $fields = "*"; $limit = ''; $order = ''; $start = 0; if ($startd) { $start = $startd; } if ($fld) { $fields = $fld; } if ($whered) { $where = " WHERE {$whered} "; } if ($limitd) { $limit = " LIMIT {$start},{$limitd} "; } $query = "SELECT SQL_CALC_FOUND_ROWS {$fields} FROM ott_spincard_used {$where} GROUP BY spincard ORDER BY created desc {$limit} "; /* echo $query; */ try { //$rs = $this->cache->get($cache_name); //if(!$rs || $this->clearcache){ $rs = $this->dbAAA2()->fetchAll($query); // $this->cache->set($cache_name,$rs,$this->cache_time); //} } catch (Exception $e) { Doo::logger()->alert($e); Doo::logger()->writeLogs("log" + date('Y-m-d') + ".txt", false); } return $rs; }
private function orderPrintPaySUCCESS($orderid = 0) { // $params['orderid'] = '12413237022015092911210327222'; $params['orderid'] = $orderid; $params['pagesize'] = $this->getCurPage() . ',' . Doo::conf()->pagesize; //验证此订单是本人的,店长打印则跳开 if ($this->shopMaster() == false) { $params['uid'] = $_SESSION['uid']; } if (!isset($params['orderid']) || trim($params['orderid']) == '') { $this->alert('data null2'); exit; } $order = DBproxy::getProcedure('Manage')->setDimension(2)->getOrder($params); if ($order['total'] < '1') { $this->alert('data null2'); exit; } //打印处理 if ($order['data'][$params['orderid']]['0']['printStatus'] > 0 && $this->shopMaster() == false) { $this->alert('已经打印过了'); exit; } //订单的状态是否能打印,在微信接口验证 $orderStatus = $this->queryOrder($params['orderid'], $order['data'][$params['orderid']][0]['status']); if ($orderStatus != 'SUCCESS') { $this->alert('未支付成功,order status err '); exit; } //D($order['data'][$params['orderid']]); foreach ($order['data'][$params['orderid']] as $key => $value) { $title[] = $value['title'] . ' ' . $value['wxprice'] . ' (' . $value['sum'] . ')'; } $msgNo = time() + rand(1, 9999); /* 自由格式的打印内容 */ if ($order['data'][$params['orderid']]['0']['waimai'] == '1') { $waimai = '外卖单 '; $sb = ' ******'; $addr = "\r\n" . '送货地址:' . $order['data'][$params['orderid']]['0']['addr'] . "\r\n"; } else { $waimai = '堂食单'; $addr = ''; $sb = ''; } $freeMessage = array('memberCode' => MEMBER_CODE, 'msgDetail' => ' 微微乐餐饮欢迎您订购 ' . $waimai . ': 序号:' . $order['data'][$params['orderid']]['0']['oid'] . $sb . ' 条目 单价(元) 数量 ----------------- ' . implode("\r\n", $title) . ' ----------------- 合计:' . $order['data'][$params['orderid']]['0']['allPrice'] . '元 店名:' . $order['data'][$params['orderid']]['0']['shopname'] . $addr . ' 联系电话:' . $order['data'][$params['orderid']]['0']['phone'] . ' 订购时间:' . date('Y-m-d H:i:s', $order['data'][$params['orderid']]['0']['addtime']) . ' ', 'deviceNo' => DEVICE_NO, 'msgNo' => $msgNo); $order = DBproxy::getProcedure('Manage')->setDimension(2)->upOrderPrint($order['data'][$params['orderid']]['0']['oid']); $printStatus = $this->sendFreeMessage($freeMessage); Doo::logger()->info('time:' . date("Y-m-d H:i:s", time()) . "\tip:" . getIP() . "\tprintStatus:" . $printStatus, 'print'); if ($printStatus == 0) { echo '打印请求/任务中队列中,等待打印'; $order = DBproxy::getProcedure('Manage')->setDimension(2)->upOrderPrint($order['data'][$params['orderid']]['0']['oid']); } elseif ($printStatus == 1) { echo '打印任务已完成/请求数据已打印'; $order = DBproxy::getProcedure('Manage')->setDimension(2)->upOrderPrint($order['data'][$params['orderid']]['0']['oid']); } elseif ($printStatus == 2) { echo '打印任务/请求失败'; } else { echo $printStatus; } return $msgNo; }
/** * 后置控制器 * @param [type] $routeResult [description] * @return [type] [description] */ public function afterRun($routeResult) { parent::afterRun($routeResult); switch ($this->_action) { case 'add': case 'del': case 'mod': Doo::logger()->info(' ip:' . getIP() . ' user:'******' ip:' . getIP() . ' user:' . $this->_opname); break; } }
public function destroy() { try { //init model Doo::db()->beginTransaction(); $m = new $this->model(); //set id $m->id = $this->params['id']; //delete $m->delete(); //commit Doo::db()->commit(); $this->res->success = true; $this->res->data = $id; } catch (Exception $e) { Doo::db()->rollBack(); $this->res->success = false; $this->res->message .= "Unable to Delete! "; $this->res->data = mySQLExceptions::parse($e->getMessage()); Doo::logger()->err("DB Delete Error! " . $e->getMessage(), 'db'); } }
<?php require_once 'version.php'; include './protected/config/common.conf.php'; include './protected/config/routes.conf.php'; include './protected/config/db.conf.php'; #Just include this for production mode //include $config['BASE_PATH'].'deployment/deploy.php'; include $config['BASE_PATH'] . 'Doo.php'; include $config['BASE_PATH'] . 'app/DooConfig.php'; # Uncomment for auto loading the framework classes. //spl_autoload_register('Doo::autoload'); //var_dump($config); exit; Doo::conf()->set($config); # remove this if you wish to see the normal PHP error view. //include $config['BASE_PATH'].'diagnostic/debug.php'; # database usage //Doo::useDbReplicate(); #for db replication master-slave usage //Doo::db()->setMap($dbmap); Doo::db()->setDb($dbconfig, $config['APP_MODE']); Doo::db()->sql_tracking = true; #for debugging/profiling purpose Doo::app()->route = $route; # Uncomment for DB profiling Doo::logger()->beginDbProfile('doowebsite'); Doo::app()->run(); Doo::logger()->endDbProfile('doowebsite'); Doo::logger()->rotateFile(20); echo Doo::logger()->writeDbProfiles(); //Doo::logger()->trace('message...'); //echo Doo::logger()->showLogs();