php 将DEDE下载次数表里的数据批量写入对应文档表扩展字段中
将DEDE下载次数表里的数据批量写入对应文档表扩展字段中 [代码片段(33行)]
<?php /** * 数据库数据转换处理 */ require_once (dirname(__FILE__) . "/include/common.inc.php"); /** * 数据表数据写入字段 * * @author chenjianlong <939238564@qq.com> */ function fodo(){ global $dsql; function Downloads($id){ global $dsql; $count = $dsql->GetOne("SELECT id,SUM(downloads) AS totals FROM `1sohu_downloads` WHERE id='$id' GROUP BY id "); $sid = $count['id'];$totals = $count['totals']; if(!empty($count)){ mysql_query("UPDATE `1sohu_addonsoft` SET `downloads` = '$totals' WHERE `1sohu_addonsoft`.`aid` =$sid"); } } $count = $dsql->GetOne("SELECT count(*) AS count FROM `1sohu_downloads`"); $count = $count['count']; for($i=1;$i<=$count;$i++){ $idsql = $dsql->GetOne("SELECT id FROM `1sohu_downloads` WHERE id='$i' GROUP BY id "); if($idsql){ $id = $idsql['id']; Downloads($id); } } } fodo(); ?> //该片段来自于http://outofmemory.cn
- 上一篇:php CURL封装类
- 下一篇:斐波那契数列 一个php编写的斐波那契数列代码片段
精彩图集
精彩文章