Revived MySQL support
This commit is contained in:
parent
ccf7464d6f
commit
70f55f65b4
8 changed files with 74 additions and 9 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 9b27422f780840f9814d8fc49017716cf6e7fea6
|
Subproject commit 22910a186efbcb9bc86a3ae3eb6f4aff34096406
|
|
@ -31,7 +31,7 @@ class TagSearchParser extends AbstractSearchParser
|
||||||
if ($orderByString == 'popularity')
|
if ($orderByString == 'popularity')
|
||||||
$this->statement->setOrderBy('post_count', $orderDir);
|
$this->statement->setOrderBy('post_count', $orderDir);
|
||||||
elseif ($orderByString == 'alpha')
|
elseif ($orderByString == 'alpha')
|
||||||
$this->statement->setOrderBy('tag.name', $orderDir);
|
$this->statement->setOrderBy(new Sql\CaseFunctor('tag.name'), $orderDir);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -72,7 +72,7 @@ abstract class AbstractSearchService
|
||||||
|
|
||||||
$stmt = new Sql\SelectStatement();
|
$stmt = new Sql\SelectStatement();
|
||||||
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
$stmt->setColumn(new Sql\AliasFunctor(new Sql\CountFunctor('1'), 'count'));
|
||||||
$stmt->setSource($innerStmt);
|
$stmt->setSource($innerStmt, 'inner_stmt');
|
||||||
|
|
||||||
return Database::fetchOne($stmt)['count'];
|
return Database::fetchOne($stmt)['count'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
ALTER TABLE post ADD COLUMN comment_date INTEGER DEFAULT NULL;
|
ALTER TABLE post ADD COLUMN comment_date INTEGER DEFAULT NULL;
|
||||||
|
|
||||||
CREATE TRIGGER comment_update_date AFTER UPDATE ON comment FOR EACH ROW
|
DROP TRIGGER comment_update;
|
||||||
|
|
||||||
|
CREATE TRIGGER comment_update AFTER UPDATE ON comment FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE post SET comment_count = comment_count + 1 WHERE post.id = new.post_id;
|
||||||
|
UPDATE post SET comment_count = comment_count - 1 WHERE post.id = old.post_id;
|
||||||
UPDATE post SET comment_date = (SELECT MAX(comment_date) FROM comment WHERE comment.post_id = post.id);
|
UPDATE post SET comment_date = (SELECT MAX(comment_date) FROM comment WHERE comment.post_id = post.id);
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE TRIGGER comment_insert_date AFTER INSERT ON comment FOR EACH ROW
|
DROP TRIGGER comment_insert;
|
||||||
|
|
||||||
|
CREATE TRIGGER comment_insert AFTER INSERT ON comment FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE post SET comment_count = comment_count + 1 WHERE post.id = new.post_id;
|
||||||
UPDATE post SET comment_date = (SELECT MAX(comment_date) FROM comment WHERE comment.post_id = post.id);
|
UPDATE post SET comment_date = (SELECT MAX(comment_date) FROM comment WHERE comment.post_id = post.id);
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
ALTER TABLE favoritee ADD COLUMN fav_date INTEGER DEFAULT NULL;
|
ALTER TABLE favoritee ADD COLUMN fav_date INTEGER DEFAULT NULL;
|
||||||
ALTER TABLE post ADD COLUMN fav_date INTEGER DEFAULT NULL;
|
ALTER TABLE post ADD COLUMN fav_date INTEGER DEFAULT NULL;
|
||||||
|
|
||||||
CREATE TRIGGER favoritee_update_date AFTER UPDATE ON favoritee FOR EACH ROW
|
DROP TRIGGER favoritee_update;
|
||||||
|
|
||||||
|
CREATE TRIGGER favoritee_update AFTER UPDATE ON favoritee FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE post SET fav_count = fav_count + 1 WHERE post.id = new.post_id;
|
||||||
|
UPDATE post SET fav_count = fav_count - 1 WHERE post.id = old.post_id;
|
||||||
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE TRIGGER favoritee_insert_date AFTER INSERT ON favoritee FOR EACH ROW
|
DROP TRIGGER favoritee_insert;
|
||||||
|
|
||||||
|
CREATE TRIGGER favoritee_insert AFTER INSERT ON favoritee FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE post SET fav_count = fav_count + 1 WHERE post.id = new.post_id;
|
||||||
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE TRIGGER favoritee_delete_date AFTER DELETE ON favoritee FOR EACH ROW
|
DROP TRIGGER favoritee_delete;
|
||||||
|
|
||||||
|
CREATE TRIGGER favoritee_delete AFTER DELETE ON favoritee FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE post SET fav_count = fav_count - 1 WHERE post.id = old.post_id;
|
||||||
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
||||||
END;
|
END;
|
||||||
|
|
0
src/Upgrades/mysql/Upgrade14.sql
Normal file
0
src/Upgrades/mysql/Upgrade14.sql
Normal file
48
src/Upgrades/sqlite/Upgrade14.sql
Normal file
48
src/Upgrades/sqlite/Upgrade14.sql
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
--merge multiple triggers into singular ones
|
||||||
|
|
||||||
|
DROP TRIGGER comment_update;
|
||||||
|
DROP TRIGGER comment_update_date;
|
||||||
|
|
||||||
|
CREATE TRIGGER comment_update AFTER UPDATE ON comment FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE post SET comment_count = comment_count + 1 WHERE post.id = new.post_id;
|
||||||
|
UPDATE post SET comment_count = comment_count - 1 WHERE post.id = old.post_id;
|
||||||
|
UPDATE post SET comment_date = (SELECT MAX(comment_date) FROM comment WHERE comment.post_id = post.id);
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER comment_insert;
|
||||||
|
DROP TRIGGER comment_insert_date;
|
||||||
|
|
||||||
|
CREATE TRIGGER comment_insert AFTER INSERT ON comment FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE post SET comment_count = comment_count + 1 WHERE post.id = new.post_id;
|
||||||
|
UPDATE post SET comment_date = (SELECT MAX(comment_date) FROM comment WHERE comment.post_id = post.id);
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER favoritee_update;
|
||||||
|
DROP TRIGGER favoritee_update_date;
|
||||||
|
|
||||||
|
CREATE TRIGGER favoritee_update AFTER UPDATE ON favoritee FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE post SET fav_count = fav_count + 1 WHERE post.id = new.post_id;
|
||||||
|
UPDATE post SET fav_count = fav_count - 1 WHERE post.id = old.post_id;
|
||||||
|
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER favoritee_insert;
|
||||||
|
DROP TRIGGER favoritee_insert_date;
|
||||||
|
|
||||||
|
CREATE TRIGGER favoritee_insert AFTER INSERT ON favoritee FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE post SET fav_count = fav_count + 1 WHERE post.id = new.post_id;
|
||||||
|
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER favoritee_delete;
|
||||||
|
DROP TRIGGER favoritee_delete_date;
|
||||||
|
|
||||||
|
CREATE TRIGGER favoritee_delete AFTER DELETE ON favoritee FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE post SET fav_count = fav_count - 1 WHERE post.id = old.post_id;
|
||||||
|
UPDATE post SET fav_date = (SELECT MAX(fav_date) FROM favoritee WHERE favoritee.post_id = post.id);
|
||||||
|
END;
|
|
@ -57,7 +57,7 @@ foreach ($upgrades as $upgradePath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
\Chibi\Database::exec(new \Chibi\Sql\RawStatement($query));
|
\Chibi\Database::execUnprepared(new \Chibi\Sql\RawStatement($query));
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue