Пример #1
0
 public function updateComments($articleID, $commentID)
 {
     $strTableName = global_common::builtTableName(Model_Article::TBL_SL_ARTICLE, global_common::getTableSuffixByMonth($intID));
     $strSQL = 'call sp_update_user_comment(1,\'' . $strTableName . '\',\'' . global_mapping::ArticleID . '\',\'' . $articleID . '\',\'' . $commentID . '\')';
     $arrResult = $this->_objConnection->selectMultiCommand($strSQL);
     //global_common::writeLog("updateComments: ".$strSQL,0);
     if (!$arrResult) {
         global_common::writeLog("updateComments: " . $strSQL, 1);
         return false;
     }
     return $arrResult[0];
 }
Пример #2
0
 /**
  * lấy thông tin detail của một vài c_user,c_user_detail
  *
  * @param string $userList danh sách các id c_user
  * @param object $objConnection connect to db
  * @param string $selectField các cột sẽ lấy dữ liệu về
  * @return array thông tin các user
  * GiaTran
  */
 private function getUserDetailByMultiTable($userList, $objConnection, $selectField = '*')
 {
     // build group table - optimize select query
     $userList = global_common::splitString($userList);
     //print_r($userList);
     $arrDocInTable = array();
     foreach ($userList as $key) {
         $suffix = global_common::getTableSuffixByAlphabet($key);
         $arrDocInTable[$suffix] .= '\'' . $key . '\',';
     }
     foreach ($arrDocInTable as $iDoc) {
         $key = global_common::getTableSuffixByAlphabet(substr($iDoc, 1, 2));
         $arrDocInTable[$key] = global_common::cutLast($iDoc, 1);
         $tbName = global_common::builtTableName(Model_User::TBL_SL_USER, $key);
         $selectField = '*';
         $strSQL .= "(" . global_common::prepareQuery(global_common::SQL_SELECT_BY_CONDITION1, array($selectField, $tbName, '`UserID` IN (' . $arrDocInTable[$key] . ')')) . ') UNION ALL ';
     }
     if ($strSQL != '') {
         $strSQL = substr($strSQL, 0, strlen($strSQL) - strlen(' UNION ALL '));
     }
     if ($selectField == '') {
         $strSQL = '(select * from (' . $strSQL . ') as tbl_user)';
     } else {
         $strSQL = '(select ' . $selectField . ' from (' . $strSQL . ') as tbl_user)';
     }
     //echo $strSQL;
     return $objConnection->selectCommand($strSQL);
 }
Пример #3
0
 public function insert($commenttype, $articleid, $content)
 {
     $date = global_common::getDateTime();
     $intID = global_common::buildIDByMonth(global_common::getMaxID(self::TBL_SL_COMMENT), $date, Model_Comment::TABLE_BY_MONTHS_COMMENT);
     //echo 'Comment id:'.$intID;
     //$intID = global_common::getMaxID(self::TBL_SL_COMMENT);
     // lấy tên table c_comment_detail_ để lưu thông tin comment
     $strTableName = global_common::builtTableName(Model_Comment::TBL_SL_COMMENT, global_common::getTableSuffixByMonth($intID));
     //$strTableName = self::TBL_SL_COMMENT;
     $strSQL = global_common::prepareQuery(Model_Comment::SQL_INSERT_SL_COMMENT, array($strTableName, $intID, global_common::escape_mysql_string($commenttype), global_common::escape_mysql_string($articleid), global_common::escape_mysql_string($content), global_common::escape_mysql_string($createdby), global_common::escape_mysql_string($createddate), global_common::escape_mysql_string($modifiedby), global_common::escape_mysql_string($modifieddate), global_common::escape_mysql_string($deletedby), global_common::escape_mysql_string($deleteddate), global_common::escape_mysql_string($isdeleted), global_common::escape_mysql_string($status)));
     //echo $strSQL;
     if (!global_common::ExecutequeryWithCheckExistedTable($strSQL, Model_Comment::SQL_CREATE_TABLE_SL_COMMENT, $this->_objConnection, $strTableName)) {
         global_common::writeLog('Error add sl_comment:' . $strSQL, 1);
         return false;
     } else {
         $arrResult = global_common::updateContents($this->_objConnection, $articleid, $intID, global_common::COMMENT_TYPE);
         if (!$arrResult) {
             global_common::writeLog('sp_update_content_summary: ' . $strSQL, 1);
         }
     }
     return $intID;
 }