1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-17 00:08:17 +03:00

фиксы багов/неточностей + оптимизация SQL запросов

This commit is contained in:
Mzhelskiy Maxim 2008-10-30 06:12:44 +00:00
parent 3df02a0936
commit 7b119a4142
15 changed files with 46 additions and 96 deletions

View file

@ -1176,8 +1176,7 @@ class ActionBlog extends Action {
if ($oTopic->getPublish()) {
/**
* Добавляем коммент в прямой эфир если топик не в черновиках
*/
$this->Comment_DeleteTopicCommentOnline($oCommentNew->getTopicId());
*/
$oTopicCommentOnline=new CommentEntity_TopicCommentOnline();
$oTopicCommentOnline->setTopicId($oCommentNew->getTopicId());
$oTopicCommentOnline->setCommentId($oCommentNew->getId());

View file

@ -19,7 +19,7 @@
* Обработка персональных блогов, т.е. УРла вида /log/
*
*/
class ActionLog extends Action {
class ActionPersonalBlog extends Action {
/**
* Меню
*

View file

@ -104,7 +104,7 @@ class ActionRss extends Action {
$comments=array();
foreach ($aComments as $oComment){
$item['title']='коментар до: '.$oComment->getTopicTitle();
$item['title']='комментарии к: '.$oComment->getTopicTitle();
$item['guid']=$oComment->getTopicUrl().'#comment'.$oComment->getId();
$item['link']=$oComment->getTopicUrl().'#comment'.$oComment->getId();
$item['description']=$oComment->getText();
@ -136,7 +136,7 @@ class ActionRss extends Action {
$comments=array();
foreach ($aComments as $oComment){
$item['title']='коментар до: '.$oTopic->getTitle();
$item['title']='комментарии к: '.$oTopic->getTitle();
$item['guid']=$oTopic->getUrl().'#comment'.$oComment->getId();
$item['link']=$oTopic->getUrl().'#comment'.$oComment->getId();
$item['description']=$oComment->getText();

View file

@ -16,10 +16,7 @@
*/
class CommentEntity_TopicCommentOnline extends Entity
{
public function getCommentOnlineId() {
return $this->_aData['comment_online_id'];
}
{
public function getTopicId() {
return $this->_aData['topic_id'];
}
@ -27,10 +24,7 @@ class CommentEntity_TopicCommentOnline extends Entity
return $this->_aData['comment_id'];
}
public function setCommentOnlineId($data) {
$this->_aData['comment_online_id']=$data;
}
public function setTopicId($data) {
$this->_aData['topic_id']=$data;
}

View file

@ -110,7 +110,7 @@ class Mapper_TopicComment extends Mapper {
AND
user_id = ?d
AND
(comment_pid = ?) or (? is NULL and comment_pid is NULL)
((comment_pid = ?) or (? is NULL and comment_pid is NULL))
AND
comment_text_hash =?
";
@ -431,11 +431,10 @@ class Mapper_TopicComment extends Mapper {
}
public function AddTopicCommentOnline(CommentEntity_TopicCommentOnline $oTopicCommentOnline) {
$sql = "INSERT INTO ".DB_TABLE_TOPIC_COMMENT_ONLINE."
(topic_id,
comment_id
)
VALUES(?d, ?d)
$sql = "REPLACE INTO ".DB_TABLE_TOPIC_COMMENT_ONLINE."
SET
topic_id= ?d ,
comment_id= ?d
";
if ($iId=$this->oDb->query($sql,$oTopicCommentOnline->getTopicId(),$oTopicCommentOnline->getCommentId()))
{

View file

@ -45,7 +45,7 @@ class Viewer extends Module {
*
* @var unknown_type
*/
protected $sHtmlKeywords=SITE_KYEWORDS;
protected $sHtmlKeywords=SITE_KEYWORDS;
/**
* SEO описание страницы
*

View file

@ -646,15 +646,10 @@ class Topic extends Module {
*/
public function SetDateRead($sTopicId,$sUserId) {
$res=$this->oMapperTopic->SetDateRead($sTopicId,$sUserId);
if ($res===0) {
try {
$this->oMapperTopic->AddTopicRead($sTopicId,$sUserId);
} catch (Exception $e) {
/**
* Отлавливаем исключение, т.к. при больших нагрузках может быть конфликт при вставке. Вернее даже просто подавляем ошибку
*/
}
if ($res==1 or $res==2) {
return true;
}
return false;
}
/**
* Запоминаем число комментов при чтении топика
@ -665,15 +660,10 @@ class Topic extends Module {
*/
public function SetCountCommentLast($sTopicId,$sUserId,$iCountComment) {
$res=$this->oMapperTopic->SetCountCommentLast($sTopicId,$sUserId,$iCountComment);
if ($res===0) {
try {
$this->oMapperTopic->AddTopicCommentLast($sTopicId,$sUserId,$iCountComment);
} catch (Exception $e) {
/**
* Отлавливаем исключение, т.к. при больших нагрузках может быть конфликт при вставке. Вернее даже просто подавляем ошибку
*/
}
if ($res==1 or $res==2) {
return true;
}
return false;
}
/**
* Получаем дату прочтения топика юзером

View file

@ -919,64 +919,27 @@ class Mapper_Topic extends Mapper {
public function SetDateRead($sTopicId,$sUserId) {
$sDate=date("Y-m-d H:i:s");
$sql = "UPDATE ".DB_TABLE_TOPIC_READ."
SET date_read = ?
WHERE
topic_id = ?
and
$sql = "REPLACE ".DB_TABLE_TOPIC_READ."
SET
date_read = ? ,
topic_id = ? ,
user_id = ?
";
return $this->oDb->query($sql,$sDate,$sTopicId,$sUserId);
}
public function AddTopicRead($sTopicId,$sUserId) {
$sDate=date("Y-m-d H:i:s");
$sql = "INSERT INTO ".DB_TABLE_TOPIC_READ."
(topic_id,
user_id,
date_read
)
VALUES(?d, ?d, ?)
";
if ($this->oDb->query($sql,$sTopicId,$sUserId,$sDate)===0)
{
return true;
}
return false;
}
public function SetCountCommentLast($sTopicId,$sUserId,$iCountComment) {
$sDate=date("Y-m-d H:i:s");
$sql = "UPDATE ".DB_TABLE_TOPIC_COMMENT_LAST."
$sql = "REPLACE INTO ".DB_TABLE_TOPIC_COMMENT_LAST."
SET
comment_count_last = ? ,
date_last = ?
WHERE
user_id = ?
and
date_last = ? ,
user_id = ? ,
topic_id = ?
";
return $this->oDb->query($sql,$iCountComment,$sDate,$sUserId,$sTopicId);
}
public function AddTopicCommentLast($sTopicId,$sUserId,$iCountComment) {
$sDate=date("Y-m-d H:i:s");
$sql = "INSERT INTO ".DB_TABLE_TOPIC_COMMENT_LAST."
(topic_id,
user_id,
comment_count_last,
date_last
)
VALUES(?d, ?d, ?d, ?)
";
if ($this->oDb->query($sql,$sTopicId,$sUserId,$iCountComment,$sDate)===0)
{
return true;
}
return false;
}
public function GetDateRead($sTopicId,$sUserId) {
$sql = "SELECT
date_read

View file

@ -174,7 +174,7 @@ class Mapper_User extends Mapper {
SELECT
user_id,
user_frend_id
FROM ".DB_TABLE_FREND."
FROM ".DB_TABLE_FRIEND."
WHERE user_id = ?d
) AS uf ON uf.user_frend_id = u.user_id
@ -328,7 +328,7 @@ class Mapper_User extends Mapper {
public function AddFrend(UserEntity_Frend $oFrend) {
$sql = "INSERT INTO ".DB_TABLE_FREND."
$sql = "INSERT INTO ".DB_TABLE_FRIEND."
(user_id,
user_frend_id
)
@ -342,7 +342,7 @@ class Mapper_User extends Mapper {
}
public function DeleteFrend(UserEntity_Frend $oFrend) {
$sql = "DELETE FROM ".DB_TABLE_FREND."
$sql = "DELETE FROM ".DB_TABLE_FRIEND."
WHERE
user_id = ?d
AND
@ -356,7 +356,7 @@ class Mapper_User extends Mapper {
}
public function GetFrend($sFrendId,$sUserId) {
$sql = "SELECT * FROM ".DB_TABLE_FREND." WHERE user_id = ?d and user_frend_id = ?d ";
$sql = "SELECT * FROM ".DB_TABLE_FRIEND." WHERE user_id = ?d and user_frend_id = ?d ";
if ($aRow=$this->oDb->selectRow($sql,$sUserId,$sFrendId)) {
return new UserEntity_Frend($aRow);
}
@ -367,7 +367,7 @@ class Mapper_User extends Mapper {
$sql = "SELECT
u.*
FROM
".DB_TABLE_FREND." as uf,
".DB_TABLE_FRIEND." as uf,
".DB_TABLE_USER." as u
WHERE
uf.user_id = ?d
@ -390,7 +390,7 @@ class Mapper_User extends Mapper {
$sql = "SELECT
u.*
FROM
".DB_TABLE_FREND." as uf,
".DB_TABLE_FRIEND." as uf,
".DB_TABLE_USER." as u
WHERE
uf.user_frend_id = ?d

View file

@ -104,7 +104,7 @@ define('ACL_CAN_VOTE_USER',-1); // порог рейтинга при котор
* Прочие настройки
*/
define('SITE_NAME','LiveStreet - бесплатный движок социальной сети'); // название сайта
define('SITE_KYEWORDS','движок, livestreet, блоги, социальная сеть, бесплатный, php'); // seo keywords
define('SITE_KEYWORDS','движок, livestreet, блоги, социальная сеть, бесплатный, php'); // seo keywords
define('SITE_DESCRIPTION','LiveStreet - официальный сайт бесплатного движка социальной сети'); // seo description
define('SITE_CLOSE_MODE',false); // использовать закрытый режим работы сайта, сайт будет доступен только авторизованным пользователям
define('USER_USE_ACTIVATION',false); // использовать активацию при регистрации или нет

View file

@ -26,7 +26,7 @@ return array(
'profile' => 'ActionProfile',
'my' => 'ActionMy',
'blog' => 'ActionBlog',
'log' => 'ActionLog',
'log' => 'ActionPersonalBlog',
'top' => 'ActionTop',
'index' => 'ActionIndex',
'new' => 'ActionNew',

View file

@ -36,7 +36,7 @@ define('DB_TABLE_FAVOURITE_TOPIC',DB_PREFIX_TABLE.'favourite_topic');
define('DB_TABLE_TALK',DB_PREFIX_TABLE.'talk');
define('DB_TABLE_TALK_USER',DB_PREFIX_TABLE.'talk_user');
define('DB_TABLE_TALK_COMMENT',DB_PREFIX_TABLE.'talk_comment');
define('DB_TABLE_FREND',DB_PREFIX_TABLE.'frend');
define('DB_TABLE_FRIEND',DB_PREFIX_TABLE.'friend');
define('DB_TABLE_TOPIC_CONTENT',DB_PREFIX_TABLE.'topic_content');
define('DB_TABLE_TOPIC_QUESTION_VOTE',DB_PREFIX_TABLE.'topic_question_vote');
define('DB_TABLE_USER_ADMINISTRATOR',DB_PREFIX_TABLE.'user_administrator');

View file

@ -84,10 +84,8 @@ $sql = "SELECT res.* FROM (
$res=mysql_query($sql,$link);
while ($row=mysql_fetch_assoc($res)) {
//var_dump($row);
$sql2 = "INSERT INTO ".DB_TABLE_TOPIC_COMMENT_ONLINE."
(topic_id,comment_id)
values(".$row['topic_id'].",'".mysql_escape_string($row['comment_id'])."')
$sql2 = "REPLACE INTO ".DB_TABLE_TOPIC_COMMENT_ONLINE."
SET topic_id = ".$row['topic_id']." ,comment_id = ".$row['comment_id']."
";
mysql_query($sql2,$link);
}

View file

@ -235,8 +235,15 @@ ALTER TABLE `prefix_topic_comment_last`
ALTER TABLE `prefix_user` ADD `user_settings_notice_new_friend` TINYINT( 1 ) NOT NULL DEFAULT '1';
-- изменяем имя таблицы на правильное с точки зрения грамотеев английского языка..
RENAME TABLE `social`.`prefix_frend` TO `social`.`prefix_friend` ;
-- добавляем уникальный индекс
ALTER TABLE `prefix_topic_comment_online` DROP INDEX `topic_id` ,
ADD UNIQUE `topic_id` ( `topic_id` ) ;
--
-- ВНИМАНИЕ!!! То что ниже нужно выполнить только после запуска скрипта convert.php !!!! иначе УДАЛЯТСЯ ВСЕ ТОПИКИ!!!!!
--