From a6452faddf9796cb99fe64743c96768a6238ee58 Mon Sep 17 00:00:00 2001 From: tayyebi Date: Mon, 28 May 2018 18:23:22 +0430 Subject: [PATCH] just an edit ;) --- database/script.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/script.sql b/database/script.sql index 0646ddb..f46bb9f 100644 --- a/database/script.sql +++ b/database/script.sql @@ -63,14 +63,14 @@ CREATE TABLE IF NOT EXISTS `post_details` (`MasterID` INT, `Title` INT, `ID` INT -- View `post_contents` -- ----------------------------------------------------- DROP TABLE IF EXISTS `post_contents`; -USE `gordcms`; + CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `post_contents` AS select `P`.`MasterId` AS `MasterId`,`P`.`Id` AS `Id`,`P`.`Title` AS `Title`,`P`.`Submit` AS `Submit`,`P`.`Type` AS `Type`,`P`.`Level` AS `Level`,`P`.`Body` AS `Body`,`P`.`UserId` AS `UserId`,`P`.`Status` AS `Status`,`P`.`RefrenceId` AS `RefrenceId`,`P`.`Index` AS `Index`,`P`.`Deleted` AS `Deleted`,`P`.`ContentDeleted` AS `ContentDeleted`,`users`.`Username` AS `Username`,(select `P0`.`Content` AS `Content` from `posts` `P0` where ((`P0`.`Content` is not null) and (`P`.`MasterId` = `P0`.`MasterId`)) order by `P0`.`Submit` desc limit 1) AS `Content`,(select `P1`.`Submit` AS `D1` from `posts` `P1` where ((`P1`.`Content` is not null) and (`P`.`MasterId` = `P1`.`MasterId`)) order by `P1`.`Submit` desc limit 1) AS `D1`,(select `P2`.`Submit` AS `D2` from `posts` `P2` where ((`P2`.`ContentDeleted` = 1) and (`P`.`MasterId` = `P2`.`MasterId`)) order by `P2`.`Submit` desc limit 1) AS `D2` from (`posts` `P` join `users` on((`P`.`UserId` = `users`.`Id`))) where (`P`.`Id` in (select max(`posts`.`Id`) from `posts` group by `posts`.`MasterId`) and (`P`.`Deleted` = 0)); -- ----------------------------------------------------- -- View `post_details` -- ----------------------------------------------------- DROP TABLE IF EXISTS `post_details`; -USE `gordcms`; + CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `post_details` AS select `T`.`MasterId` AS `MasterID`,`T`.`Title` AS `Title`,`T`.`Id` AS `ID`,`T`.`Submit` AS `Submit`,`T`.`UserId` AS `UserID`,`T`.`Username` AS `Username`,`T`.`Body` AS `Body`,`T`.`Type` AS `Type`,`T`.`Level` AS `Level`,`T`.`RefrenceId` AS `RefrenceID`,`T`.`Index` AS `Index`,`T`.`Status` AS `Status`,(case when (`T`.`D2` >= `T`.`D1`) then NULL else `T`.`Content` end) AS `Content` from `post_contents` `T`; SET SQL_MODE=@OLD_SQL_MODE;