+ Changed from MySQL to MySQLi native driver.

+ Added 2 new functions in DataBase class: fetch($query) and num_rows($query)

git-svn-id: https://svn.pioder.pl/uf-svn/uF@20 72ec579a-5ced-4fa4-82f3-afba5d98df2f
This commit is contained in:
pioder
2009-05-03 10:50:00 +00:00
parent 6cc36dc266
commit b1f37b6ea5
43 changed files with 296 additions and 193 deletions

View File

@@ -202,7 +202,7 @@ function AddSkins()
global $default_skin;
$all='';
$query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
while($t = @mysql_fetch_array($query))
while($t = DataBase::fetch($query))
{
if ($t['name']==$default_skin)
@@ -278,7 +278,7 @@ function TotalPosts()
{
$sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
$result = mysql_fetch_array($query);
$result = DataBase::fetch($query);
$result = $result['p_id'];
return($result);
@@ -338,15 +338,13 @@ function ViewSkinName()
$result = $forum_config['defaultskin'];
}
$sql = "SELECT * FROM `".SKINS_TABLE."` WHERE `s_id`='$result'";
$result = mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
$result = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
return $result['name'];
}
function GenerateLastPost($id, $type)
{
$last_post = '';
{
switch ($type)
{
/** field lastpost in forum format
@@ -356,8 +354,8 @@ function GenerateLastPost($id, $type)
{
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".POSTS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE `f_id`='$id' ORDER BY `ptime` LIMIT 1";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain last post in forum', true);
$post_count = @mysql_num_rows($query);
$result = mysql_fetch_array($query);
$post_count = DataBase::num_rows($query);
$result = DataBase::fetch($query);
$last_post .= $result['tp_id'];
$last_post .= ':';
@@ -385,7 +383,55 @@ function GenerateLastPost($id, $type)
{
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in topic');
$result = mysql_fetch_array($query);
$result = DataBase::fetch($query);
$last_post .= $result['tp_id'];
$last_post .= ':';
$last_post .= $result['u_id'];
$last_post .= ':';
$last_post .= $result['ptime'];
$last_post .= ':';
$last_post .= $result['rank'];
$last_post .= ':';
$last_post .= $result['nick'];
$sql = "UPDATE ".TOPICS_TABLE." SET
`lastpost`='$last_post'
WHERE `t_id`='$id'";
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in topic');
break;
}
}
}
function GeneratePosts($id, $type)
{
switch ($type)
{
case 1: //for forum
{
$sql = "SELECT COUNT (`p_id`) AS 'count', `f_id` FROM ".POSTS_TABLE." WHERE `f_id`='$id'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain posts in forum', true);
$post_count = DataBase::num_rows($query);
$result = DataBase::fetch($query);
$posts = $result['count'];
$sql = "UPDATE ".FORUMS_TABLE." SET
`posts`='$last_post'
WHERE `f_id`='$id'";
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in forum');
break;
}
/** field lastpost in topic format
tp_id:u_id:ptime:rank:nick
*/
case 2: //for topic
{
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in topic');
$result = DataBase::fetch($query);
$last_post .= $result['tp_id'];
$last_post .= ':';