예제 #1
0
파일: Post.php 프로젝트: JCQS04/myimouto
 public function delete_from_database()
 {
     $this->runCallbacks('destroy', function () {
         $this->delete_file();
         self::connection()->executeSql('UPDATE pools SET post_count = post_count - 1 WHERE id IN (SELECT pool_id FROM pools_posts WHERE post_id = ?)', $this->id);
         self::connection()->executeSql('UPDATE tags SET post_count = post_count - 1 WHERE id IN (SELECT tag_id FROM posts_tags WHERE post_id = ?)', $this->id);
         # MI: Destroying pool posts manually so their histories are deleted by foreign keys.
         # This is done in Pool too. This could be done with a MySQL trigger.
         PoolPost::destroyAll('post_id = ?', $this->id);
         self::connection()->executeSql("DELETE FROM posts WHERE id = ?", $this->id);
     });
 }
예제 #2
0
파일: Pool.php 프로젝트: JCQS04/myimouto
 protected function destroy_pool_posts()
 {
     PoolPost::destroyAll('pool_id = ?', $this->id);
 }