public function searchArticleByTitle($key, $categoryId) { if ($categoryId == 0) { $this->mArticles = Product::SearchArticleByTitle($key); echo json_encode($this->mArticles); } else { $this->mArticles = Product::SearchCategoryArticleByTitle($key, $categoryId); echo json_encode($this->mArticles); } }