当前位置: 首页>>代码示例>>PHP>>正文


PHP R::genSlots方法代码示例

本文整理汇总了PHP中R::genSlots方法的典型用法代码示例。如果您正苦于以下问题:PHP R::genSlots方法的具体用法?PHP R::genSlots怎么用?PHP R::genSlots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::genSlots方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCoolUsers

 public static function getCoolUsers($goal)
 {
     $query = 'SELECT id FROM user WHERE cool = 1 ORDER BY RANDOM() LIMIT ?';
     $userIds = array_map(function ($x) {
         return intval($x['id']);
     }, R::getAll($query, [$goal]));
     if (empty($userIds)) {
         return [];
     }
     $query = 'id IN (' . R::genSlots($userIds) . ')';
     $result = R::findAll('user', $query, $userIds);
     return array_map(function ($x) {
         return $x->box();
     }, $result);
 }
开发者ID:jonnyguio,项目名称:graph,代码行数:15,代码来源:Model_User.php

示例2: process

 public function process(array $documents, &$context)
 {
     $franchiseIds = [];
     $franchiseIds[] = self::mediaToKey($context->media);
     foreach ($context->relationData as $relation) {
         if ($relation['media'] != $context->media->media) {
             continue;
         }
         if ($relation['type'] == MediaRelation::Character) {
             continue;
         }
         if (BanHelper::isFranchiseCouplingBanned($relation['media'], $relation['mal_id'], $context->media->media, $context->media->mal_id)) {
             continue;
         }
         $franchiseIds[] = self::mediaToKey($relation);
     }
     foreach (R::findAll('media', 'media||mal_id IN (' . R::genSlots($franchiseIds) . ')', $franchiseIds) as $relatedMedia) {
         $franchiseIds[] = $relatedMedia->franchise;
     }
     $franchiseId = reset($franchiseIds);
     $media =& $context->media;
     $media->franchise = $franchiseId;
     R::store($media);
     $query = 'UPDATE media SET franchise = ? WHERE franchise IN (' . R::genSlots($franchiseIds) . ')';
     R::exec($query, array_merge([$franchiseId], $franchiseIds));
 }
开发者ID:Lucas8x,项目名称:graph,代码行数:26,代码来源:MediaSubProcessorFranchises.php

示例3: getFromIdList

 public static function getFromIdList($list)
 {
     $allEntries = [];
     foreach (array_chunk($list, Config::$maxDbBindings) as $chunk) {
         $query = 'SELECT m.*, m.id AS media_id FROM media m WHERE CONCAT_WS(\'\', m.media, m.mal_id) IN (' . R::genSlots($chunk) . ')';
         $rows = R::getAll($query, $chunk);
         $entries = array_map(function ($entry) {
             return new Model_MixedUserMedia($entry);
         }, $rows);
         $allEntries = array_merge($allEntries, $entries);
     }
     return $allEntries;
 }
开发者ID:asmdz,项目名称:malgraph,代码行数:13,代码来源:Model_MixedUserMedia.php

示例4: SUM

}
/* 5、客户上电分布 */
try {
    $pue_month_custcabin = R::getAll('   SELECT x.relate_id, ' . '          x.dc_name, ' . '          x.cust_name, ' . '          SUM(x.shangdianshu) AS shangdianshu ' . '     FROM (     SELECT CASE WHEN @var_dc_name = a.dc_name THEN @rank := @rank + 1 ELSE @rank := 1 END  AS rank, ' . '                       dc_id                                                                           AS relate_id, ' . '                       @var_dc_name := a.dc_name                                                       AS dc_name, ' . '                       CASE WHEN @rank <= 4 THEN cust_name ELSE "其它" END                             AS cust_name, ' . '                       shangdianshu                                                                    AS shangdianshu ' . '                  FROM (    SELECT h.dc_id, ' . '                                   h.fullname            AS dc_name, ' . '                                   g.shortname           AS cust_name, ' . '                                   COUNT(*)              AS shangdianshu ' . '                              FROM pro_room_cabinet a ' . '                        INNER JOIN pro_room b ' . '                                ON a.pro_room_id = b.pro_room_id ' . '                        INNER JOIN room c ' . '                                ON b.room_id = c.room_id ' . '                        INNER JOIN sub_project d ' . '                                ON b.sub_project_id = d.sub_project_id ' . '                        INNER JOIN project f ' . '                                ON d.project_id = f.project_id ' . '                        INNER JOIN customer g ' . '                                ON f.customer_id = g.customer_id ' . '                        INNER JOIN dc h ' . '                                ON c.dc_id = h.dc_id ' . '                             WHERE (    a.elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH), "%Y-%m-01 00:00:00") ' . '                                    AND a.elec_time <= DATE_FORMAT(LAST_DAY(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH)), "%Y-%m-%d 23:59:59"))' . '                               AND h.dc_id IN (' . R::genSlots($dc_ids) . ') ' . '                          GROUP BY dc_name, cust_name ' . '                          ORDER BY dc_name, shangdianshu DESC ' . '                       ) a ' . '            CROSS JOIN (SELECT @var_dc_name := NULL, @rank := NULL ) b ' . '          ) x' . ' GROUP BY relate_id, dc_name, cust_name ' . ' ORDER BY dc_name, rank ', $dc_ids);
} catch (Exception $e) {
    exit('DB resource select failed 5 \\n' . $e->getMessage());
}
/* 6、客户下电分布 */
try {
    $pue_month_custcabout = R::getAll('   SELECT x.relate_id, ' . '          x.dc_name, ' . '          x.cust_name, ' . '          SUM(x.xiadianshu) AS xiadianshu ' . '     FROM (     SELECT CASE WHEN @var_dc_name = a.dc_name THEN @rank := @rank + 1 ELSE @rank := 1 END  AS rank, ' . '                       dc_id                                                                           AS relate_id, ' . '                       @var_dc_name := a.dc_name                                                       AS dc_name, ' . '                       CASE WHEN @RANK <= 4 THEN CUST_NAME ELSE "其它" END                             AS cust_name, ' . '                       xiadianshu                                                                      AS xiadianshu ' . '                  FROM (   SELECT h.dc_id, ' . '                                  h.fullname           AS dc_name, ' . '                                  g.shortname          AS cust_name, ' . '                                  COUNT(*)             AS xiadianshu ' . '                             FROM pro_room_cabinet a ' . '                       INNER JOIN pro_room b ' . '                               ON a.pro_room_id = b.pro_room_id ' . '                       INNER JOIN room c ' . '                               ON b.room_id = c.room_id ' . '                       INNER JOIN sub_project d ' . '                               ON b.sub_project_id = d.sub_project_id ' . '                       INNER JOIN project f ' . '                               ON d.project_id = f.project_id ' . '                       INNER JOIN customer g ' . '                               ON f.customer_id = g.customer_id ' . '                       INNER JOIN dc h ' . '                               ON c.dc_id = h.dc_id ' . '                            WHERE (    a.down_elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH), "%Y-%m-01 00:00:00")  ' . '                                   AND a.down_elec_time <= DATE_FORMAT(LAST_DAY(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH)), "%Y-%m-%d 23:59:59")) ' . '                              AND h.dc_id IN (' . R::genSlots($dc_ids) . ') ' . '                         GROUP BY dc_name, cust_name ' . '                         ORDER BY dc_name, xiadianshu DESC ' . '                       ) a ' . '            CROSS JOIN (SELECT @var_dc_name := NULL, @rank := NULL ) b ' . '          ) x' . ' GROUP BY relate_id, dc_name, cust_name ' . ' ORDER BY dc_name, rank ', $dc_ids);
} catch (Exception $e) {
    exit('DB resource select failed 6 \\n' . $e->getMessage());
}
/* 7、客户用电较上月浮动最大Top5 */
try {
    $pue_month_cust5top = R::getAll(' SELECT final.rank, ' . '        final.dc_id        AS relate_id, ' . '        final.dc_id, ' . '        final.dc_name, ' . '        final.cust_name, ' . '        final.bianhuashuKW ' . '   FROM ' . '   (    SELECT IF(@dc_id = total.dc_id, @rank := @rank + 1, @rank := 1) AS rank, ' . '               @dc_id := total.dc_id, ' . '               total.dc_id, ' . '               total.dc_name, ' . '               total.cust_name, ' . '               total.bianhuashuKW ' . '          FROM (        SELECT l.dc_id, ' . '                               ll.cust_name, ' . '                               _month.dc_name, ' . '                               CASE WHEN l.ITKW IS NULL OR ll.LITKW IS NULL THEN 0 ' . '                                    ELSE ROUND(l.ITKW - ll.LITKW, 2) ' . '                                END AS bianhuashuKW ' . '                          FROM (   SELECT dc.dc_id, ' . '                                          dc.fullname AS dc_name, ' . '                                          DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH), "%Y%m")*1 AS last_month, ' . '                                          DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 3 ELSE 2 END) MONTH), "%Y%m")*1 AS last_last_month ' . '                                     FROM dc ' . '                                    WHERE dc.dc_id IN (' . R::genSlots($dc_ids) . ') ' . '                               ) AS _month ' . '                     LEFT JOIN (   SELECT c.dc_id, ' . '                                          f.shortname AS cust_name, ' . '                                          SUM(a.record_elec / DATEDIFF(a.record_endtime, a.record_starttime) / 24) AS ITKW, ' . '                                          a.record_month ' . '                                     FROM record_pro_room_elec a, ' . '                                          pro_room b, ' . '                                          room c, ' . '                                          sub_project d, ' . '                                          project e, ' . '                                          customer f ' . '                                    WHERE a.pro_room_id = b.pro_room_id ' . '                                      AND b.room_id = c.room_id ' . '                                      AND b.sub_project_id = d.sub_project_id ' . '                                      AND a.record_month = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH), "%Y%m") ' . '                                      AND d.project_id = e.project_id ' . '                                      AND e.customer_id = f.customer_id ' . '                                 GROUP BY c.dc_id, cust_name ' . '                               ) l ' . '                            ON l.record_month = _month.last_month ' . '                           AND l.dc_id = _month.dc_id ' . '                     LEFT JOIN (   SELECT c.dc_id, ' . '                                          f.shortname AS cust_name, ' . '                                          SUM(a.record_elec / DATEDIFF(a.record_endtime, a.record_starttime) / 24) AS LITKW, ' . '                                          a.record_month ' . '                                     FROM record_pro_room_elec a, ' . '                                          pro_room b, ' . '                                          room c, ' . '                                          sub_project d, ' . '                                          project e, ' . '                                          customer f ' . '                                    WHERE a.pro_room_id = b.pro_room_id ' . '                                      AND b.room_id = c.room_id ' . '                                      AND b.sub_project_id = d.sub_project_id ' . '                                      AND a.record_month = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 3 ELSE 2 END) MONTH), "%Y%m") ' . '                                      AND d.project_id = e.project_id ' . '                                      AND e.customer_id = f.customer_id ' . '                                 GROUP BY c.dc_id, cust_name ' . '                               ) ll ' . '                            ON ll.record_month = _month.last_last_month ' . '                           AND ll.dc_id = _month.dc_id ' . '                           AND l.dc_id = ll.dc_id ' . '                           AND l.cust_name = ll.cust_name ' . '                      ORDER BY l.dc_id, l.ITKW - ll.LITKW DESC ' . '                ) total ' . '     CROSS JOIN (SELECT @dc_id := NULL, @rank := 1 ) r ' . '   ) final ' . ' WHERE final.rank <= 5 ', $dc_ids);
} catch (Exception $e) {
    exit('DB resource select failed 7 \\n' . $e->getMessage());
}
R::close();
SAVE:
/* 写入报警 */
/* ≥5%且<10%  XXX数据中心上月PUE环比上升/下降 YY% */
/* ≥10%  XXX数据中心上月PUE环比上升/下降 YY% */
R::addDatabase('alarm', $GLOBALS['db_alarm_url'], $GLOBALS['db_alarm_user'], $GLOBALS['db_alarm_pass']);
R::selectDatabase('alarm');
if (!R::testConnection()) {
    exit('DB alarm connect failed \\n' . $e->getMessage());
}
R::freeze(TRUE);
try {
开发者ID:adexbn,项目名称:gds_alarm,代码行数:31,代码来源:pue_month.php

示例5: genre

 public static function genre($genreIds, $list)
 {
     if (empty($list)) {
         return [];
     }
     if (!is_array($genreIds)) {
         $genreIds = [$genreIds];
     }
     $tblName = Model_MixedUserMedia::createTemporaryTable($list);
     $query = 'SELECT * FROM mediagenre mg INNER JOIN ' . $tblName . ' ON mg.media_id = ' . $tblName . '.media_id WHERE mg.mal_id IN (' . R::genSlots($genreIds) . ')';
     $data = R::getAll($query, $genreIds);
     Model_MixedUserMedia::dropTemporaryTable($tblName);
     $data = array_map(function ($x) {
         return $x['media_id'];
     }, $data);
     $data = array_flip($data);
     return function ($row) use($data) {
         return isset($data[$row->media_id]);
     };
 }
开发者ID:asmdz,项目名称:malgraph,代码行数:20,代码来源:UserMediaFilter.php

示例6: PDO

try {
    $db = new PDO($GLOBALS['db_remedy_url'], $GLOBALS['db_remedy_user'], $GLOBALS['db_remedy_pass'], array(PDO::ATTR_PERSISTENT => true));
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = $db->prepare(' SELECT Distinct remedy_login_id ' . '   FROM CTM_PeopleUserSupportGroupFunc ' . '  WHERE Functional_Role = \'Work Order Assignee\' ' . '    AND Organization = \'数据中心服务部\' ', [PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]);
    $sql->execute();
    $staff_dcs_accounts = $sql->fetchAll(PDO::FETCH_ASSOC);
    $staff_dcs_account_vals = array_column($staff_dcs_accounts, 'remedy_login_id');
    $sql = null;
} catch (PDOException $e) {
    exit('DB remedy select failed \\n' . $e->getMessage());
}
R::addDatabase('portal', $GLOBALS['db_portal_url'], $GLOBALS['db_portal_user'], $GLOBALS['db_portal_pass']);
R::selectDatabase('portal');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    if (!empty($staff_dcs_account_vals)) {
        $staff_dcss = R::getAll('SELECT name        AS fullname, ' . '       email       AS email, ' . '       cell_phone  AS mobilenumber' . '  FROM gdsportal.auth_user ' . ' WHERE username IN (' . R::genSlots($staff_dcs_account_vals) . ')', $staff_dcs_account_vals);
    }
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error portal', 'details' => $e->getMessage()]);
    die;
}
R::close();
// Return
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'true', 'staff_dcss' => $staff_dcss], JSON_UNESCAPED_UNICODE);
die;
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:staff_dcs.php

示例7: work

 public static function work(&$controllerContext, &$viewContext)
 {
     try {
         if (empty($_POST['sender'])) {
             throw new Exception('No sender specified');
         }
         $sender = $_POST['sender'];
         if (empty($_POST['action'])) {
             throw new Exception('No action specified');
         }
         $action = $_POST['action'];
         if (empty($_POST['model-ids'])) {
             throw new Exception('No model ids specified');
         }
         $modelIds = array_map('trim', preg_split('/[,;]/', $_POST['model-ids']));
         $chosenMedia = [];
         $chosenUsers = [];
         switch ($sender) {
             case 'media':
                 $chosenMedia = self::getChosenMedia($modelIds);
                 break;
             case 'user':
                 $chosenUsers = self::getChosenUsers($modelIds);
                 break;
             default:
                 throw new Exception('Unknown sender: ' . $sender);
         }
         if ($action == 'refresh') {
             $num = 0;
             $startTime = microtime(true);
             $mediaProcessors = [Media::Anime => new AnimeProcessor(), Media::Manga => new MangaProcessor()];
             $userProcessor = new UserProcessor();
             foreach ($chosenMedia as $media => $ids) {
                 foreach ($ids as $id) {
                     $mediaProcessors[$media]->process($id);
                     ++$num;
                 }
             }
             foreach ($chosenUsers as $user) {
                 $userProcessor->process($user);
                 ++$num;
             }
             $viewContext->messageType = 'info';
             $viewContext->message = sprintf('Successfully processed %d entities in %.02fs', $num, microtime(true) - $startTime);
         } elseif ($action == 'wipe-cache') {
             $deleted = 0;
             foreach ($chosenUsers as $userName) {
                 $cache = new Cache();
                 $cache->setPrefix($userName);
                 foreach ($cache->getAllFiles() as $path) {
                     $deleted++;
                     unlink($path);
                 }
             }
             $viewContext->messageType = 'info';
             $viewContext->message = 'Deleted ' . $deleted . ' files';
         } elseif ($action == 'unban' or $action == 'soft-ban' or $action == 'hard-ban') {
             switch ($action) {
                 case 'unban':
                     $banState = BanHelper::USER_BAN_NONE;
                     break;
                 case 'soft-ban':
                     $banState = BanHelper::USER_BAN_QUEUE_ONLY;
                     break;
                 case 'hard-ban':
                     $banState = BanHelper::USER_BAN_TOTAL;
                     break;
                 default:
                     throw new Exception('Wrong ban state');
             }
             $changed = 0;
             foreach ($chosenUsers as $userName) {
                 BanHelper::setUserBanState($userName, $banState);
                 ++$changed;
             }
             $viewContext->messageType = 'info';
             $viewContext->message = sprintf('Successfully updated %d users', $changed);
         } elseif ($action == 'reset-franchise') {
             $num = 0;
             foreach ($chosenMedia as $media => $ids) {
                 $query = 'UPDATE media SET franchise = NULL WHERE media = ? AND mal_id IN (' . R::genSlots($ids) . ')';
                 R::exec($query, array_merge([$media], $ids));
                 $num += count($ids);
             }
             $viewContext->messageType = 'info';
             $viewContext->message = sprintf('Successfully reset franchise for %d entities. Don\'t forget to refresh them now!', $num);
         } elseif ($action == 'remove') {
             $num = 0;
             foreach ($chosenMedia as $media => $ids) {
                 $query = 'DELETE FROM media WHERE media = ? AND mal_id IN (' . R::genSlots($ids) . ')';
                 R::exec($query, array_merge([$media], $ids));
                 $num += count($ids);
             }
             $viewContext->messageType = 'info';
             $viewContext->message = sprintf('Successfully removed %d entities.', $num);
         } else {
             throw new Exception('Unknown action: ' . $action);
         }
     } catch (Exception $e) {
         $viewContext->messageType = 'error';
//.........这里部分代码省略.........
开发者ID:Lucas8x,项目名称:graph,代码行数:101,代码来源:AdminControllerProcessorModule.php

示例8: SUM

}
/* 4、上周新上下电机柜总数 */
try {
    $pue_week_cabio = R::getAll('     SELECT c.dc_id          AS relate_id, ' . '            h.fullname       AS dc_name, ' . '            SUM(CASE ' . '                     WHEN     a.elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y-%m-%d 06:00:00") ' . '                          AND a.elec_time <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY), "%Y-%m-%d 06:00:00") ' . '                     THEN 1 ' . '                     ELSE 0 ' . '                END ' . '            )                AS shangdianshu, ' . '            SUM(CASE ' . '                    WHEN      a.down_elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y-%m-%d 06:00:00") ' . '                          AND a.down_elec_time <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY), "%Y-%m-%d 06:00:00") ' . '                    THEN 1 ' . '                    ELSE 0 ' . '                END ' . '            )                AS xiadianshu ' . '       FROM pro_room_cabinet a ' . ' INNER JOIN pro_room b ' . '         ON a.pro_room_id = b.pro_room_id ' . ' INNER JOIN room c ' . '         ON b.room_id = c.room_id ' . ' INNER JOIN dc h ' . '         ON c.dc_id = h.dc_id ' . '      WHERE (    (     a.elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y-%m-%d 06:00:00") ' . '                   AND a.elec_time <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY),  "%Y-%m-%d 06:00:00") ' . '                 ) ' . '              OR (     a.down_elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y-%m-%d 06:00:00") ' . '                   AND a.down_elec_time <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY),  "%Y-%m-%d 06:00:00") ' . '                 ) ' . '            ) ' . '        AND h.dc_id IN (' . R::genSlots($dc_ids) . ') ' . '   GROUP BY c.dc_id ', $dc_ids);
} catch (Exception $e) {
    exit('DB resource select failed 4 \\n' . $e->getMessage());
}
/* 5、客户上电分布 */
try {
    $pue_week_custcabin = R::getAll('   SELECT x.relate_id, ' . '          x.dc_name, ' . '          x.cust_name, ' . '          SUM(x.shangdianshu) AS shangdianshu ' . '     FROM (     SELECT IF(@var_dc_name = a.dc_name, @rank := @rank + 1, @rank := 1)        AS rank, ' . '                       dc_id                                                               AS relate_id, ' . '                       @var_dc_name := a.dc_name                                           AS dc_name, ' . '                       CASE WHEN @RANK <= 4 THEN cust_name ELSE "其它" END                 AS cust_name, ' . '                       shangdianshu                                                        AS shangdianshu ' . '                  FROM (   SELECT h.dc_id      AS dc_id, ' . '                                  h.fullname   AS dc_name, ' . '                                  g.shortname  AS cust_name, ' . '                                  COUNT(*)     AS shangdianshu ' . '                             FROM pro_room_cabinet a ' . '                       INNER JOIN pro_room b ' . '                               ON a.pro_room_id = b.pro_room_id ' . '                       INNER JOIN room c ' . '                               ON b.room_id = c.room_id ' . '                       INNER JOIN sub_project d ' . '                               ON b.sub_project_id = d.sub_project_id ' . '                       INNER JOIN project f ' . '                               ON d.project_id = f.project_id ' . '                       INNER JOIN customer g ' . '                               ON f.customer_id = g.customer_id ' . '                       INNER JOIN dc h ' . '                               ON c.dc_id = h.dc_id ' . '                            WHERE (a.elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y-%m-%d 06:00:00") ' . '                              AND a.elec_time  <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY), "%Y-%m-%d 06:00:00")) ' . '                              AND h.dc_id IN (' . R::genSlots($dc_ids) . ') ' . '                         GROUP BY dc_id, dc_name, cust_name ' . '                         ORDER BY dc_id, dc_name, shangdianshu DESC ' . '                       ) a ' . '            CROSS JOIN (SELECT @var_dc_name := NULL, @rank := NULL ) b ' . '          ) x' . ' GROUP BY relate_id, dc_name, cust_name ' . ' ORDER BY dc_name, rank ', $dc_ids);
} catch (Exception $e) {
    exit('DB resource select failed 5 \\n' . $e->getMessage());
}
/* 6、客户下电分布 */
try {
    $pue_week_custcabout = R::getAll('   SELECT x.relate_id, ' . '          x.dc_name, ' . '          x.cust_name, ' . '          SUM(x.xiadianshu) AS xiadianshu ' . '     FROM (     SELECT IF(@var_dc_name = a.dc_name, @rank := @rank + 1, @rank := 1)       AS rank, ' . '                       dc_id                                                              AS relate_id, ' . '                       @var_dc_name := a.dc_name                                          AS dc_name, ' . '                       CASE WHEN @RANK <= 4 THEN cust_name ELSE "其它" END                AS cust_name, ' . '                       xiadianshu                                                         AS xiadianshu ' . '                  FROM (   SELECT h.dc_id         AS dc_id, ' . '                                  h.fullname      AS dc_name, ' . '                                  g.shortname     AS cust_name, ' . '                                  COUNT(*)        AS xiadianshu ' . '                             FROM pro_room_cabinet a ' . '                       INNER JOIN pro_room b ' . '                               ON a.pro_room_id = b.pro_room_id ' . '                       INNER JOIN room c ' . '                               ON b.room_id = c.room_id ' . '                       INNER JOIN sub_project d ' . '                               ON b.sub_project_id = d.sub_project_id ' . '                       INNER JOIN project f ' . '                               ON d.project_id = f.project_id ' . '                       INNER JOIN customer g ' . '                               ON f.customer_id = g.customer_id ' . '                       INNER JOIN dc h ' . '                               ON c.dc_id = h.dc_id ' . '                            WHERE (a.down_elec_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y-%m-%d 06:00:00") ' . '                              AND a.down_elec_time  <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY),  "%Y-%m-%d 06:00:00")) ' . '                              AND h.dc_id IN (' . R::genSlots($dc_ids) . ') ' . '                         GROUP BY dc_name, cust_name ' . '                         ORDER BY dc_name, xiadianshu DESC ' . '                       ) a ' . '            CROSS JOIN (SELECT @var_dc_name := NULL, @rank := NULL ) b ' . '          ) x' . ' GROUP BY relate_id, dc_name, cust_name ' . ' ORDER BY dc_name, rank ', $dc_ids);
} catch (Exception $e) {
    exit('DB resource select failed 6 \\n' . $e->getMessage());
}
R::close();
SAVE:
/* 写入:报警信息 */
/* ≥5%且<10%    XXX数据中心上周PUE环比上升/下降 YY% */
/* ≥10%         XXX数据中心上周PUE环比上升/下降 YY% */
R::addDatabase('alarm', $GLOBALS['db_alarm_url'], $GLOBALS['db_alarm_user'], $GLOBALS['db_alarm_pass']);
R::selectDatabase('alarm');
if (!R::testConnection()) {
    exit('DB alarm connect failed \\n' . $e->getMessage());
}
R::freeze(TRUE);
try {
开发者ID:adexbn,项目名称:gds_alarm,代码行数:31,代码来源:pue_week.php

示例9: IFNULL

try {
    $dc_view_2_1 = R::getAll('     SELECT /* 基础信息 */ ' . '            dc.fullname                                                                                      AS dc_name,              /* 数据中心名称 */ ' . '            IFNULL(dc.room_area, 0) + IFNULL(dc.office_area, 0) + IFNULL(dc.stationarea_area, 0)             AS dc_total_area,        /* 总建筑面积(㎡) */ ' . '            raa.area_c                                                                                         AS dc_rack_area,         /* 总机房面积(㎡) */ ' . '            raa.elec_c                                                                                         AS dc_elec,              /* 总规划电力(KW) */ ' . '  ' . '            /* 能效 */ ' . '            r.actual_pue                                                                                     AS nx_pue,               /* 周PUE */ ' . '            ROUND((r.actual_pue - last_r.actual_pue) / last_r.actual_pue * 100, 2)                           AS nx_pue_chg,           /* 周PUE 变化百分比 */ ' . '            r.total_elec                                                                                     AS nx_total_elec,        /* 周总用电量 */ ' . '            ROUND((r.total_elec - last_r.total_elec) / last_r.total_elec * 100, 2)                           AS nx_total_elec_chg,    /* 周总用电量 变化百分比 */ ' . '            r.it_elec                                                                                        AS nx_it_elec,           /* 周IT用电量 */ ' . '            ROUND((r.it_elec - last_r.it_elec) / last_r.it_elec * 100, 2)                                    AS nx_it_elec_chg,       /* 周IT用电量 变化百分比 */ ' . '  ' . '            /* 资源 */ ' . '            ifnull(r.field_rent_rate ,"漏填" )                                                                              AS zy_field_rent,        /* 周场租率 */ ' . '            r.field_rent_rate - last_r.field_rent_rate                                                       AS zy_field_rent_chg,    /* 周场租率 变化百分点 */ ' . '            ifnull(r.it_capacity_rate ,"漏填" )                                                                              AS zy_it_capability,     /* 周IT负载率 */ ' . '            r.it_capacity_rate - last_r.it_capacity_rate                                                     AS zy_it_capability_chg, /* 周IT负载率 变化百分点 */ ' . '            r.actual_field_rack                                                                              As zy_field_rack,        /* 周进场机柜数 */ ' . '            ROUND((r.actual_field_rack - last_r.actual_field_rack) / last_r.actual_field_rack * 100, 2)      AS zy_field_rack_chg,    /* 周进场机柜数 变化百分比 */ ' . '            r.actual_elec_rack                                                                               AS zy_elec_rack,         /* 周上电机柜数 */ ' . '            ROUND((r.actual_field_rack - last_r.actual_field_rack) / last_r.actual_field_rack * 100, 2)      AS zy_elec_rack_chg,     /* 周上电机柜数 变化百分比 */ ' . '            r.remaining_unit                                                                                 AS zy_remaining_unit     /* 周剩余标准机柜位 */ ' . '       FROM dc ' . '  LEFT JOIN dc_weekly_elec_record r ' . '         ON r.dc_id = dc.dc_id ' . '        AND r.record_week = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 10 DAY), "%Y%m%d") left outer join (SELECT dc_id,SUM(area_c) AS area_c ,SUM(ups_out_energy) AS elec_c  FROM room GROUP BY dc_id) raa on raa.dc_id =dc.dc_id ' . '  LEFT JOIN dc_weekly_elec_record last_r ' . '         ON last_r.dc_id = dc.dc_id ' . '        AND last_r.record_week = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) + 17 DAY), "%Y%m%d") ' . '      WHERE dc.fullname IN (' . R::genSlots($dc_names) . ') ', $dc_names);
} catch (Exception $e) {
    exit('DB portal select failed 2_1 \\n' . $e->getMessage());
}
/* 能效信息   -- 月PUE      -- 月用电情况 -- 月总电量
 * 资源信息   -- 场租率     -- IT负载率   -- 上电机柜数 -- 进场机柜数 -- 剩余机柜位 */
try {
    $dc_view_2_2 = R::getAll('     SELECT _month.dc_name                                        AS dc_name,                  /* 数据中心名称 */ ' . '  ' . '            /* 能效 */ ' . '            a.pue                                                 AS nx_pue_month,             /* 月PUE */ ' . '            a.huanbiPUE                                           AS nx_pue_chg_month,         /* 月PUE 变化百分比 */ ' . '            a.shijidc                                             AS nx_total_elec_month,      /* 月总用电量 */ ' . '            ROUND(a.huanbi_shijidc / a.shijidc, 2)                AS nx_total_elec_chg_month,  /* 月总用电量 变化百分比 */ ' . '            a.shijiIT                                             AS nx_it_elec_month,         /* 月IT用电量 */ ' . '            ROUND(a.huanbiIT / a.shijiIT, 2)                      AS nx_it_elec_chg_month,     /* 月IT用电量 变化百分比 */ ' . '  ' . '            /* 资源 */ ' . '            ROUND(a.hetong_jiguiwei *100 / a.guihuajiguiwei,2)                                                    AS zy_field_rent_month,        /* 月场租率 */ ' . '            ROUND(a.hetong_jiguiwei / a.guihuajiguiwei,2) - ROUND(b.hetong_jiguiwei / b.guihuajiguiwei, 2)   AS zy_field_rent_chg_month,    /* 月场租率 变化百分点 */ ' . '            ROUND(a.shijiITKW *100/ a.guihuadianliang,2)                                                         AS zy_it_capability_month,     /* 月IT负载率 */ ' . '            ROUND(a.shijiITKW / a.guihuadianliang,2) - ROUND(b.shijiITKW / b.guihuadianliang, 2)             AS zy_it_capability_chg_month, /* 月IT负载率 变化百分点 */ ' . '            a.jinchang_jigui                                                                                 As zy_field_rack_month,        /* 月进场机柜数 */ ' . '            ROUND(a.huanbijinchang_jigui *100/ a.jinchang_jigui, 2)                                              AS zy_field_rack_chg_month,    /* 月进场机柜数 变化百分比 */ ' . '            a.shangdian_jiguishu                                                                             AS zy_elec_rack_month,         /* 月上电机柜数 */ ' . '            ROUND(a.huanbishangdian_jiguishu *100 / a.shangdian_jiguishu, 2)                                      AS zy_elec_rack_chg_month,     /* 月上电机柜数 变化百分比 */ ' . '            a.shengyu_jiguiwei                                                                               AS zy_remaining_unit_month     /* 月剩余标准机柜位 */ ' . '       FROM ( SELECT dc.dc_id, ' . '                     dc.fullname AS dc_name, ' . '                     DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 2 ELSE 1 END) MONTH), "%Y%m")*1 AS last_month, ' . '                     DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (CASE WHEN DAY(NOW()) < 11 THEN 3 ELSE 2 END) MONTH), "%Y%m")*1 AS last_last_month ' . '                FROM dc ' . '            ) AS _month ' . '  LEFT JOIN dcrm_his.report_dc a ' . '         ON _month.last_month = a.yuefen ' . '        AND _month.dc_id = a.dc_id' . '  LEFT JOIN dcrm_his.report_dc b ' . '         ON _month.last_last_month = b.yuefen ' . '        AND _month.dc_id = b.dc_id ' . '      WHERE _month.dc_name IN (' . R::genSlots($dc_names) . ') ', $dc_names);
} catch (Exception $e) {
    exit('DB portal select failed 2_2 \\n' . $e->getMessage());
}
/* 新增客户项目条线查询数据
 * 项目数 -- 近三月离场项目 -- 近三月进场项目 -- 上月离场项目 -- 上月进场项目 -- 近三月进场机柜 -- 近三月离场机柜 -- 上月进场机柜 -- 上月离场机柜 */
try {
    $dc_view_18 = R::getAll('     SELECT dc.fullname, /*数据中心*/ ' . '            COUNT(DISTINCT CASE WHEN sp.is_released = 0 THEN sp.sub_project_id ELSE NULL END)                                                AS project_cnt,                /* 项目数 */ ' . '            COUNT(DISTINCT CASE WHEN     sp.released_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 3 MONTH), "%Y-%m-"), "01") ' . '                                     AND sp.released_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN sp.sub_project_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS project_release_threemonth, /* 近三月离场项目 */ ' . '            COUNT(DISTINCT CASE WHEN     sp.create_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 3 MONTH), "%Y-%m-"), "01") ' . '                                     AND sp.create_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN sp.sub_project_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS project_in_threemonth,      /* 近三月进场项目 */ ' . '            COUNT(DISTINCT CASE WHEN     sp.released_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 1 MONTH), "%Y-%m-"), "01") ' . '                                     AND sp.released_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN sp.sub_project_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS project_release_onemonth,   /* 上月离场项目 */ ' . '            COUNT(DISTINCT CASE WHEN     sp.create_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 1 MONTH), "%Y-%m-"), "01") ' . '                                     AND sp.create_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN sp.sub_project_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS project_in_onemonth,        /* 上月进场项目 */ ' . '            COUNT(DISTINCT CASE WHEN     prc.field_in_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 3 MONTH), "%Y-%m-"), "01") ' . '                                     AND prc.field_in_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN prc.pro_room_cabinet_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS cabinet_in_threemonth,     /* 近三月进场机柜 */ ' . '            COUNT(DISTINCT CASE WHEN     prc.field_out_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 3 MONTH), "%Y-%m-"), "01") ' . '                                     AND prc.field_out_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN prc.pro_room_cabinet_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS cabinet_out_threemonth,    /* 近三月离场机柜 */ ' . '            COUNT(DISTINCT CASE WHEN     prc.field_in_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 1 MONTH), "%Y-%m-"), "01") ' . '                                     AND prc.field_in_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN prc.pro_room_cabinet_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS cabinet_in_onemonth,       /* 上月进场机柜 */ ' . '            COUNT(DISTINCT CASE WHEN     prc.field_out_time > CONCAT(DATE_FORMAT(LAST_DAY(NOW() - INTERVAL 1 MONTH), "%Y-%m-"), "01") ' . '                                     AND prc.field_out_time < LAST_DAY(NOW() - INTERVAL 1 MONTH) ' . '                                THEN prc.pro_room_cabinet_id ' . '                                ELSE NULL ' . '                            END )                                                                                                            AS cabinet_out_onemonth       /* 上月离场机柜 */ ' . '       FROM dc ' . ' INNER JOIN room r               ON dc.dc_id = r.dc_id ' . ' INNER JOIN pro_room pr          ON r.room_id = pr.room_id ' . ' INNER JOIN sub_project sp       ON sp.sub_project_id = pr.sub_project_id ' . ' INNER JOIN pro_room_cabinet prc ON pr.pro_room_id = prc.pro_room_id ' . '      WHERE dc.fullname IN (' . R::genSlots($dc_names) . ') ' . '   GROUP BY dc.fullname ', $dc_names);
} catch (Exception $e) {
    exit('DB portal select failed 2 \\n' . $e->getMessage());
}
R::close();
/***************************************/
/********* PART 3: Remedy DB ***********/
/***************************************/
try {
    $db = new PDO($GLOBALS['db_remedy_url'], $GLOBALS['db_remedy_user'], $GLOBALS['db_remedy_pass'], array(PDO::ATTR_PERSISTENT => true));
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    exit('DB remedy select failed \\n' . $e->getMessage());
}
/* 设备信息 -- 关键设备数   -- 关键设备维保覆盖率  -- 关键设备维保覆盖率(区分 自行维保 && 供应商维保)
            -- UPS设备数    -- UPS设备维保覆盖率   -- 冷水机组设备数   -- 冷水机组维保覆盖率
开发者ID:adexbn,项目名称:gds_alarm,代码行数:31,代码来源:dc_view.php

示例10: show_Update

    public function show_Update()
    {
        $maxPX = 4;
        $userID = $this->user->getID();
        // check if new x/y pos is a valid position
        if (!is_numeric($_POST['x']) || !is_numeric($_POST['y'])) {
            $this->error('Invalid position');
        }
        // new pos
        $x = $_POST['x'] < 0 ? 0 : $_POST['x'];
        $y = $_POST['y'] < 0 ? 0 : $_POST['y'];
        // old pos
        $om = $this->mapPosition;
        // you cant move to much at once
        $deltaX = abs($om->x - $x);
        $deltaY = abs($om->y - $y);
        // skip if player did not move
        if ($deltaX != 0 || $deltaY != 0) {
            if ($deltaX > $maxPX || $deltaY > $maxPX) {
                $this->output('player_position', array($om->x, $om->y));
                $this->error('moved_to_far');
            }
            // update to new pos
            $om->x = $x;
            $om->y = $y;
            foreach ($this->teleportMap[$om->map] as $teleportPoint) {
                if ($om->x == $teleportPoint["x"] && $om->y == $teleportPoint["y"]) {
                    // check if key is needed
                    if (isset($teleportPoint["keys"])) {
                        $array = $teleportPoint["keys"];
                        $ct = R::getCell('SELECT
											COUNT(inventory.id)
									FROM
										inventory, item
									WHERE
										item.type IN (' . R::genSlots($teleportPoint["keys"]) . ')
									AND
										inventory.user_id = ' . $this->user->getID(), $teleportPoint["keys"]);
                        if ($ct == 0) {
                            continue;
                        }
                    }
                    $om->map = $teleportPoint["target"]["map"];
                    $om->x = $teleportPoint["target"]["x"];
                    $om->y = $teleportPoint["target"]["y"];
                }
            }
            //R::store($om);
            R::exec('UPDATE map_position SET x = ?, y = ?, map = ? WHERE user_id = ?', array($om->x, $om->y, $om->map, $this->user->getID()));
        }
        $this->output('player_position', array($om->x, $om->y));
        $this->output('map', $om->map);
        // get surrounding players
        /*$players = R::find('map_position', ' map = ? AND user_id != ?', array(
        			$om->map,
        			$this->user->getID()
        		));*/
        // get surrounding npcs, cached
        $npcs = RCached::find('map_npc', ' map = ?', array($om->map), date('d.m.Y'));
        $p = array();
        $players = R::getAll('SELECT
			map_position.x as x,
			map_position.y as y,

			user.id as userid,
			user.username as username,
			user.characterImage as ucharacter,

			COUNT(session.id) as isOnline

		FROM

			map_position, user, session

		WHERE

			map_position.map = ? AND
			map_position.user_id != ? AND
			user.id = map_position.user_id AND
			session.user_id = user.id AND
			session.expires > ?', array($om->map, $this->user->getId(), time()));
        foreach ($players as $playerPos) {
            if ($playerPos['x'] == null) {
                continue;
            }
            $p['p' . $playerPos['userid']] = array('name' => $playerPos['username'], 'id' => $playerPos['userid'], 'x' => $playerPos['x'], 'y' => $playerPos['y'], 'character' => $playerPos['ucharacter'], 'is_npc' => false, 'look_direction' => 2, 'npc_type' => '');
        }
        /*
        foreach ($players as $playerPos) {
        	if (!$playerPos->user->isOnline()) {
        		continue;
        	}
        
        	$p['p'.$playerPos->user->id] = array('name' => $playerPos->user->username,
        										 'x' => $playerPos->x,
        										 'y' => $playerPos->y,
        										 'id' => $playerPos->user->id,
        										 'character' => $playerPos->user->characterImage,
        										 'is_npc' => false,
        									     'look_direction' => 2,
//.........这里部分代码省略.........
开发者ID:agrafix,项目名称:managerslife,代码行数:101,代码来源:Ajax_Map.class.php

示例11: exit

<?php

require 'api_rb.php';
require 'api_db.php';
// Query get name, title, skill
R::addDatabase('kayako', $GLOBALS['db_kayako_url'], $GLOBALS['db_kayako_user'], $GLOBALS['db_kayako_pass']);
R::selectDatabase('kayako');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    $staff_csc_ids = R::getCell(' SELECT TRIM(BOTH "," FROM REPLACE(REPLACE(GROUP_CONCAT(DISTINCT com_staff), ",,", ","), ",,", ",")) cscs ' . '   FROM supportsr.order_service_company ' . '  WHERE com_staff IS NOT NULL AND com_staff != "" ');
    if (!empty($staff_csc_ids)) {
        $id_array = explode(',', $staff_csc_ids);
        $staff_cscs = R::getAll(' SELECT s.fullname, s.email, s.mobilenumber ' . '   FROM kayako_fusion.swstaff s ' . '  WHERE s.staffid IN (' . R::genSlots($id_array) . ')', $id_array);
    }
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error portal', 'details' => $e->getMessage()]);
    die;
}
R::close();
// Return
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'true', 'staff_cscs' => $staff_cscs], JSON_UNESCAPED_UNICODE);
die;
开发者ID:adexbn,项目名称:gds_wechat,代码行数:27,代码来源:staff_csc.php

示例12: search

function search($query, $category_id = null, $page = 1)
{
    $where = ['shop_id IS NOT NULL'];
    $params = [];
    if (!empty($query)) {
        $where[] = "(MATCH(title) AGAINST(?))";
        $params[] = "%{$query}%";
    }
    if ($category_id) {
        $children = R::load("category", $category_id)->ownCategoryList;
        $categoryAndChildrenIds = array_merge([$category_id], array_map(function ($c) {
            return $c->id;
        }, $children));
        $slots = R::genSlots($categoryAndChildrenIds);
        $where[] = "category_id IN ({$slots})";
        $params = array_merge($params, $categoryAndChildrenIds);
    }
    $pageSize = 10;
    $offset = ($page - 1) * $pageSize;
    $results = R::find("item", implode(" AND ", $where) . " LIMIT {$offset}, {$pageSize}", $params);
    foreach ($results as $item) {
        $item->shop;
        // Load shop data for export
    }
    $pageStart = ($page - 1) * $pageSize + 1;
    $pageEnd = $pageStart + $pageSize - 1;
    if ($pageEnd > count($results)) {
        $pageEnd = count($results);
    }
    return ['query' => $query, 'results' => $results, 'count' => count($results), 'page' => $page, 'pageSize' => $pageSize, 'start' => $pageStart, 'end' => $pageEnd];
}
开发者ID:darwish,项目名称:skyhigh,代码行数:31,代码来源:util.php

示例13: exit

    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    $user_email = R::getCell('SELECT email' . '  FROM wxcsc_users' . ' WHERE openid = :openid' . ' LIMIT 1', [':openid' => $user_openid]);
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error wechat', 'details' => $e->getMessage()]);
    die;
}
R::close();
_log(json_encode(['openid' => $user_openid, 'user_email' => $user_email]));
// Query
R::addDatabase('kayako', $GLOBALS['db_kayako_url'], $GLOBALS['db_kayako_user'], $GLOBALS['db_kayako_pass']);
R::selectDatabase('kayako');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    $user = R::getRow('     SELECT a.fullname AS name, ' . '            c.organizationname AS organization,' . '            a.phone AS phone,' . '            b.email AS email,' . '            d.com_century AS dc_id' . '       FROM kayako_fusion.swusers a' . ' INNER JOIN kayako_fusion.swuseremails b ' . '         ON a.userid = b.linktypeid' . ' INNER JOIN kayako_fusion.swuserorganizations c' . '         ON a.userorganizationid = c.userorganizationid' . '  LEFT JOIN supportsr.order_service_company d' . '         ON d.com_id = c.userorganizationid' . '      WHERE b.email = :email' . '        AND b.linktype = 1', [':email' => $user_email]);
    $user_dc_id_arr = explode(',', $user['dc_id']);
    $user_dc = R::getAssoc('SELECT name' . '  FROM supportsr.esr_companylist' . ' WHERE id IN (' . R::genSlots($user_dc_id_arr) . ')', $user_dc_id_arr);
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
    die;
}
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'true', 'user' => $user, 'user_dc' => $user_dc], JSON_UNESCAPED_UNICODE);
die;
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:user_info.php

示例14: testTransactions

 /**
  * Test Transactions.
  * 
  * @return void
  */
 public function testTransactions()
 {
     testpack('transactions');
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::commit();
     asrt(R::count('bean'), 1);
     R::wipe('bean');
     R::freeze(1);
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::rollback();
     asrt(R::count('bean'), 0);
     R::freeze(FALSE);
     testpack('genSlots');
     asrt(R::genSlots(array('a', 'b')), '?,?');
     asrt(R::genSlots(array('a')), '?');
     asrt(R::genSlots(array()), '');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:26,代码来源:Misc.php

示例15: header

R::close();
// Check
if (empty($users_wechat) || count($users_wechat) == 0) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'No data found']);
    die;
}
// Kayako
R::addDatabase('kayako', $GLOBALS['db_kayako_url'], $GLOBALS['db_kayako_user'], $GLOBALS['db_kayako_pass']);
R::selectDatabase('kayako');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
$emails = array_column($users_wechat, 'email');
try {
    $users_kayako = R::getAll('       SELECT u.fullname, IFNULL(o.organizationname, "-") AS organizationname ' . '         FROM kayako_fusion.swuseremails e ' . '   INNER JOIN kayako_fusion.swusers u ' . '           ON e.linktypeid = u.userid ' . '          AND e.linktype = 1 ' . '    LEFT JOIN kayako_fusion.swuserorganizations o ' . '           ON u.userorganizationid = o.userorganizationid ' . '        WHERE e.email IN (' . R::genSlots($emails) . ') ' . '     ORDER BY e.email ASC ', $emails);
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
    die;
}
R::close();
// Merge
$users_1 = array_combine($emails, $users_wechat);
$users_2 = array_combine($emails, $users_kayako);
$users = array_merge_recursive($users_1, $users_2);
// Return
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'true', 'all' => $users_count, 'users' => $users], JSON_UNESCAPED_UNICODE);
die;
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:manage_bind.php


注:本文中的R::genSlots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。