public function indexAction() { Model\Publish::sidebar(); exit; // $result = Model\Theme\Resource::showByName(2, 'article'); // var_dump($result);exit; $article = Model\Article::show(8); Model\Publish::article($article); $smarty = Comm\Smarty::init(); $smarty->display('tpl:article', ['var' => '<u>b</u>']); return false; }
private function digg(Article $article) { if (Model::factory('UserDigg')->where('user_id', $this->user->id)->where('article_id', $this->input->data('article_id'))->find_one()) { $this->error('You already digg this article'); } try { ORM::get_db()->beginTransaction(); if (!Model::factory('UserDigg')->create(array('user_id' => $this->user->id, 'article_id' => $article->id))->save()) { $this->error('Digg create error'); } $article->set_expr('digg_count', '`digg_count` + 1'); $article->save(); ORM::get_db()->exec("UPDATE `user` SET `digged_count` = `digged_count` + 1 WHERE `id` = '" . $article->user_id . "'"); ORM::get_db()->commit(); $article = $this->loadArticle(); $this->data['digg_count'] = $article->digg_count; } catch (\PDOException $e) { ORM::get_db()->rollBack(); // @TODO Logging $this->error('Digg error because of the bad database'); } $this->ok('Digg ok'); }
public function testQueryBuilder() { $this->assertEquals(Article::repository()->createQueryBuilder('alias'), Article::queryBuilder('alias')); }
public function testFind() { $article = $this->_insertArticle(); $result = \Model\Article::find(array('title' => $article->title)); $this->assertInstanceOf('\\Mawelous\\Yamop\\Mapper', $result); $cursor = $result->getCursor(); $this->assertEquals(1, count($cursor)); }
public function testJoinToNull() { $this->_saveArticleWithAuthor(); self::$_dbConnection->articles->insert(array('title' => 'test', 'author' => null)); $articles = \Model\Article::getMapper()->find()->join('author', '\\Model\\Author')->get(); $article = array_shift($articles); $this->assertAttributeNotEmpty('author', $article); $this->assertAttributeInstanceOf('\\Model\\Author', 'author', $article); $article = array_shift($articles); $this->assertAttributeSame(null, 'author', $article); }
/** * マイページ * * @access public * @return Response */ public function action_index() { $view = \View::forge('mypage/index'); $view->set_global('article', Article::get_list_all()); return $view; }
public function testOffsetGet() { $article = new Article(); $article->setTitle('Doctrator'); $this->assertSame('Doctrator', $article['title']); }
/** * 記事カテゴリー一覧 * * @access public * @return View */ public function action_category() { $view = \View::forge('article/category'); $category = Article::category_list(); $view->set_global('category', $category); return $view; }