コード例 #1
0
ファイル: credit.php プロジェクト: dw250100785/shopnc
 function syncredit($uids, $cids)
 {
     $apps = $notify = array();
     $myApp = $this->base->load('app');
     $applist = $myApp->applist();
     $fields = array('uid');
     $sp = 0;
     foreach ($applist as $key => $app) {
         if (!$app['uc']) {
             $fields[] = 'app' . $key;
             if ($key == $this->base->appid) {
                 $apps[$key] = 1;
             } elseif (array_intersect($cids, $this->getRelate($key))) {
                 $apps[$key] = 0;
                 $notify[] = array('uc_syncreditexists' . $key, 1);
             } else {
                 $sp = 1;
             }
         }
     }
     if (empty($apps)) {
         return;
     }
     $stats = array();
     if ($sp) {
         $query = $this->db->query("SELECT * FROM " . UC_DBTABLEPRE . "ucsyncredit WHERE uid IN(" . UC::implode($uids) . ')');
         while ($rt = $this->db->fetch_array($query)) {
             $stats[$rt['uid']] = $rt;
         }
     }
     $pwSQL = array();
     foreach ($uids as $uid) {
         $sql = array($uid);
         foreach ($applist as $key => $app) {
             if (!$app['uc']) {
                 $sql[] = isset($apps[$key]) ? $apps[$key] : (isset($stats[$uid]) ? $stats[$uid]['app' . $key] : 1);
             }
         }
         $pwSQL[] = $sql;
     }
     if ($pwSQL) {
         $this->db->update("REPLACE INTO " . UC_DBTABLEPRE . "ucsyncredit (" . implode(',', $fields) . ") VALUES " . UC::sqlMulti($pwSQL));
     }
     if ($notify) {
         $this->db->update("REPLACE INTO " . UC_DBTABLEPRE . "config (db_name, db_value) VALUES " . UC::sqlMulti($notify));
     }
 }
コード例 #2
0
ファイル: notify.php プロジェクト: noikiy/ecmall
 function add($type, $data, $exceptself = false, $exceptuc = false)
 {
     $myApp = $this->base->load('app');
     $applist = $myApp->applist();
     $pwSQL = array('action' => $type, 'param' => is_array($data) ? serialize($data) : '', 'timestamp' => $this->base->time);
     $notify = array();
     foreach ($applist as $key => $app) {
         if ($exceptself && $key == $this->base->appid || $app['uc'] && $exceptuc) {
             $pwSQL['app' . $key] = 1;
         } else {
             $notify[] = array('uc_notifyexists' . $key, 1);
         }
     }
     $this->db->query_unbuffered("INSERT INTO " . UC_DBTABLEPRE . "ucnotify SET " . UC::sqlSingle($pwSQL));
     $nid = $this->db->insert_id();
     if ($notify) {
         $this->db->query_unbuffered("REPLACE INTO " . UC_DBTABLEPRE . "config (db_name,db_value) VALUES " . UC::sqlMulti($notify));
     }
     return $nid;
 }