static function save($data) { if (is_array($data)) { $data = implode(',', $data); } return Sys::M(self::$trueTableName)->execute('INSERT INTO ' . self::$trueTableName . '(`goods_id`,`goods_img`,`price`,`discount_price`,`count`,`total_price`,`name`,`order_num`) VALUES' . $data); }
public static function getIdByActionAndModule($action, $module) { $action = strtolower($action); $module = strtolower($module); $data = Sys::M(self::$trueTableName)->select('`id`', '`action`=\'' . $action . '\' AND `module`=\'' . $module . '\'', 1); return $data ? $data['id'] : 0; }
public static function log($username, $psd, $ip = '') { if (empty($ip)) { Sys::S('core.Server.Ip'); $ip = Ip::get_client_ip(); } $data = array('username' => addslashes($username), 'psd' => addslashes($psd), 'ip' => bindec(decbin(ip2long($ip))), 'record_time' => NOW); return Sys::M(self::$trueTableName)->insert($data); }
static function getOrderGoodsInfo($goods_id) { $data = Sys::M(self::$trueTableName)->select('`logo`,`name`,`price`,`discount_price`', '`id`=' . $goods_id, 1); if (empty($data)) { $data = array('logo' => 0, 'name' => '', 'price' => 0, 'discount_price' => 0); } Sys::D('Image'); $imgData = ImageModel::getImageInfo($data['logo']); return array_merge($data, $imgData); }
public function getPager(&$data) { self::initParam($data); $where = self::getWhere($data['condition']); isset($data['extWhere']) && ($where = self::getExtWhere($where, $data['extWhere'])); self::$handle = Sys::M($data['trueTableName']); !isset($data['cols']) && ($data['cols'] = '*'); $total = self::getTotalCount($where); $pageCount = ceil($total / self::$pageSize); $limit = self::getLimit(self::$PG, self::$pageSize); $rs = self::getData($data['cols'], $where, $data['order'], $limit); return array('data' => $rs, 'paging' => array('page' => self::$PG, 'totalCount' => $total, 'numberOfPage' => $pageCount)); }
static function sync($date = 'YYmmdd') { $oM = Sys::M(self::$trueTableName); $rs = $oM->select('`num`', '`date`=\'' . $date . '\'', 1); if ($rs) { $data = array('num' => array('`num`+1', 'ignore')); return $oM->update($data, '`date`=\'' . $date . '\''); } else { $data['date'] = $date; $data['num'] = array(1, 'int'); return $oM->insert($data); } }
public static function getLatestLoginInfo($user_id, $action = LOGIN_IN) { $data = Sys::M(self::$trueTableName)->select('*', '`user_id`=' . $user_id . ' AND `action`=' . $action, 1); return $data; }
public static function getGlobalRule($group_id) { $ruleData = Sys::M(self::$trueTableName)->select('g_rules', 'id=' . $group_id, 1); return $ruleData ? $ruleData['g_rules'] : ''; }
static function sync($orderNum, $remark) { $data = array('order_num' => array($orderNum, 'string'), 'remarks' => array($remark, 'string')); return Sys::M(self::$trueTableName)->insert($data); }
static function alterAccountBaseInfo($userId, $email, $mobile) { $data = array('email' => array($email, 'string'), 'mobile' => array($mobile, 'string')); return Sys::M(self::$trueTableName)->update($data, '`id`=' . $userId); }
static function getInfoByCode($code) { $data = Sys::M(self::$trueTableName)->select('`id`,`code`,`name`,`lat`,`lng`', 'code=\'' . $code . '\'', 1); return $data ? $data : array('id' => 0, 'code' => '', 'name' => '未知', 'lat' => 0, 'lng' => 0); }
static function ifExists($fileName) { $hash = md5_file($fileName); $data = Sys::M(self::$trueTableName)->select('`id`', '`hash`=\'' . $hash . '\'', 1); return $data ? $data['id'] : 0; }
static function ifUnique($val, $table_name, $where) { $where = sprintf($where, $val); $rs = Sys::M($table_name)->select('COUNT(0) AS total', $where, 1); return $rs['total']; }
static function findStatic($storeId, $date = 'Ymd') { $data = Sys::M(self::$trueTableName)->select('store_id', 'store_id=' . $storeId . ' AND date=\'' . $date . '\'', 1); return $data; }
static function sync($orderNum, $userName, $tel, $address, $zip_code = '') { $data = array('order_num' => array($orderNum, 'string'), 'userName' => array($userName, 'string'), 'tel' => array($tel, 'string'), 'address' => array($address, 'string'), 'zip_code' => array($zip_code, 'string')); return Sys::M(self::$trueTableName)->insert($data); }
public static function getGroupId($user_id) { $group_info = Sys::M(self::$trueTableName)->select('group_id', '`mem_id`=' . $user_id . ' AND `status`=1', 1); return $group_info ? $group_info['group_id'] : 0; }
static function addOrder($userId, $storeId, $orderNum, $totalPrice) { $data = array('user_id' => array($userId, 'int'), 'store_id' => array($storeId, 'int'), 'order_num' => array($orderNum, 'string'), 'time' => array(NOW, 'int'), 'total_price' => array($totalPrice, 'float')); return Sys::M(self::$trueTableName)->insert($data); }
static function getMsgList() { $data = Sys::M(self::$trueTableName)->select('id,from_user_id,user_type,content,time', 'status=0 ORDER BY id DESC', 10); return $data; }
static function getBaseInfoById($id) { return Sys::M(self::$trueTableName)->select('id,pid,title,url', 'id=' . $id, 1); }
static function getBaseInfo($userId) { $data = Sys::M(self::$trueTableName)->select('id,no,name,tel,zip,email', 'id=' . $userId, 1); return $data; }
public static function ifHasChild($group_id) { $rs = Sys::M(self::$trueTableName)->select('id', 'pid=' . $group_id, 1); return $rs ? 1 : 0; }
static function disabledAddress($id) { $data = array('status' => array(0, 'int')); return Sys::M(self::$trueTableName)->update($data, 'id=' . $id); }