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


PHP MyDB::fetch_assoc方法代码示例

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


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

示例1: array

} else {
    $sql = "select analysisdate,{$cols} from msganalysis {$where} order by analysisdate asc";
}
$firstRow = array();
$tarr = array();
$carr = array();
$db = new MyDB();
$res = $db->query($sql);
//添加第一行
$firstRow = array('analysisdate');
foreach ($colArr as $value) {
    $firstRow[] = $value;
}
$tarr[] = $firstRow;
//对结果集进行处理,将结果封装在数组中
while ($result = $db->fetch_assoc($res)) {
    //将pv和uv转换成百分比
    if (strstr($cols, "detailpv") && $result["detailpv"] != 0) {
        $result["detailpv"] = round($result["msgcount"] / $result["detailpv"] * 100, 4);
    }
    if (strstr($cols, "detailuv") && $result["detailuv"] != 0) {
        $result["detailuv"] = round($result["usercount"] / $result["detailuv"] * 100, 4);
    }
    $trow = array();
    $crow = array();
    array_push($trow, $result["analysisdate"]);
    if ($flag == TRUE) {
        $crow["analysisdate"] = $result["analysisdate"];
        foreach ($colArr as $value) {
            array_push($trow, $result[$value]);
            $crow[$value] = $result[$value];
开发者ID:sdgdsffdsfff,项目名称:webim_analysis,代码行数:31,代码来源:getHistMsgData.php

示例2: insert_db

function insert_db($category, $majorCategory, $date)
{
    $dateArr = explode("-", $date);
    if (checkdate($dateArr[1], $dateArr[2], $dateArr[0]) == false) {
        return false;
    }
    $thisdate = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
    $nextdate = $thisdate + 3600 * 24;
    $sql = "select talkid,count(*) as msgcount from allmsg where ";
    if ($category == 0 || $category == 1001 || $category == 1002) {
        $sql .= " channel = {$category}";
    } else {
        $sql .= " channel = 0 and postcategoryid={$category} ";
    }
    if ($majorCategory !== NULL && $majorCategory != 0) {
        $sql .= " and postmajorcategoryid={$majorCategory} ";
    }
    $sql .= " and updatetime >= {$thisdate} and updatetime < {$nextdate} group by talkid order by msgcount desc";
    //echo $sql . '<br/>';
    $db = new MyDB();
    $res = $db->query($sql);
    //初始化关联数组
    $mc["c20"] = $mc["c10"] = $mc["c6"] = $mc["c5"] = $mc["c4"] = $mc["c3"] = $mc["c2"] = $mc["c1"] = 0;
    //分段统计消息数对应的会话数
    while ($result = $db->fetch_assoc($res)) {
        $msgcount = $result["msgcount"];
        if ($msgcount > 20) {
            $mc["c20"]++;
        } else {
            if ($msgcount > 10 && $msgcount <= 20) {
                $mc["c10"]++;
            } else {
                if ($msgcount >= 6 && $msgcount <= 10) {
                    $mc["c6"]++;
                } else {
                    if ($msgcount == 5) {
                        $mc["c5"]++;
                    } else {
                        if ($msgcount == 4) {
                            $mc["c4"]++;
                        } else {
                            if ($msgcount == 3) {
                                $mc["c3"]++;
                            } else {
                                if ($msgcount == 2) {
                                    $mc["c2"]++;
                                } else {
                                    if ($msgcount == 1) {
                                        $mc["c1"]++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //echo json_encode($mc);
    //insert table 'talkcount'
    $sql_insert = "insert into talkcount(analysisdate,postcategoryid,postmajorcategoryid,c20,c10,c6,c5,c4,c3,c2,c1) values('";
    $sql_insert .= $date . "',";
    $sql_insert .= $category . ",";
    $sql_insert .= $majorCategory . ",";
    $sql_insert .= $mc["c20"] . ",";
    $sql_insert .= $mc["c10"] . ",";
    $sql_insert .= $mc["c6"] . ",";
    $sql_insert .= $mc["c5"] . ",";
    $sql_insert .= $mc["c4"] . ",";
    $sql_insert .= $mc["c3"] . ",";
    $sql_insert .= $mc["c2"] . ",";
    $sql_insert .= $mc["c1"] . ")";
    //echo $sql_insert . "\n";
    $db->query($sql_insert);
    $db->close();
}
开发者ID:sdgdsffdsfff,项目名称:webim_analysis,代码行数:76,代码来源:talkcountInsertdb.php


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