function phorum_convert_selectMessages($forumdata,$link) { $sql="SELECT a.*,b.body,UNIX_TIMESTAMP(a.datestamp) as unixtime FROM ".$forumdata['table_name']." as a, ".$forumdata['table_name']."_bodies as b WHERE b.id = a.id ORDER BY a.id ASC"; $res=mysql_unbuffered_query($sql, $link); if ($err = mysql_error($link)) phorum_db_mysql_error("$err: $sql"); return $res; }
in the end, nothing more. Depending on the number of messages and users, it may take some time. */ // we try to disable the execution timeout // that command doesn't work in safe_mode :( set_time_limit(0); require './common.php'; // no need to change anything below this line $sql="select user_id, count(*) as postcnt from ".$PHORUM["message_table"]." group by user_id"; $conn = phorum_db_mysql_connect(); $res = mysql_query($sql, $conn); if ($err = mysql_error()) phorum_db_mysql_error("$err: $sql"); if(mysql_num_rows($res)) { $usercnt=0; while($row = mysql_fetch_row($res)) { $user=array("user_id"=>$row[0],"posts"=>$row[1]); phorum_user_save_simple($user); $usercnt++; } } print "$usercnt Users updated with their current postcounts. Done!<br>\n"; ?>
/** * Execute an array of queries. * * @param array $queries * * @return string */ function phorum_db_run_queries($queries){ $PHORUM = $GLOBALS["PHORUM"]; $conn = phorum_db_mysql_connect(); $retmsg = ""; foreach($queries as $sql){ $res = mysql_query($sql, $conn); if ($err = mysql_error()){ // skip duplicate column name errors if(!stristr($err, "duplicate column")){ $retmsg.= "$err<br />"; phorum_db_mysql_error("$err: $sql"); } } } return $retmsg; }