Example #1
0
 public function testDeleteById()
 {
     $this->ormMock->expects($this->once())->method('delete')->with(2);
     Model::deleteById(2);
 }
Example #2
0
 /**
  * ブログの削除処理
  */
 public function deleteByIdAndUserId($blog_id, $user_id, $options = array())
 {
     if (!parent::deleteById($blog_id, array('where' => 'user_id=?', 'params' => array($user_id)), $options)) {
         return 0;
     }
     // ブログに関連するレコード全て削除
     $tables = array('entries', 'entry_tags', 'tags', 'entry_categories', 'categories', 'comments', 'files', 'blog_settings', 'blog_templates');
     foreach ($tables as $table) {
         $sql = 'DELETE FROM ' . $table . ' WHERE blog_id=?';
         $this->executeSql($sql, array($blog_id));
     }
     // ブログディレクトリー削除
     App::removeBlogDirectory($blog_id);
     return true;
 }
Example #3
0
 /**
  * 削除処理(付随する情報も全て削除)
  */
 public function deleteById($user_id, $options = array())
 {
     $blogs_model = Model::load('Blogs');
     // ユーザーが所持しているブログを全て削除
     $blogs = $blogs_model->findByUserId($user_id);
     foreach ($blogs as $blog) {
         $blogs_model->deleteByIdAndUserId($blog['id'], $user_id);
     }
     return parent::deleteById($user_id, $options);
 }