function showArticleById($idArticle) { $articleModel = new articleModel(); $article = $articleModel->getArticle($idArticle); $commentModel = new commentModel(); $comment = $commentModel->getComments($idArticle); include 'view/viewArticle.php'; }
<?php require_once 'commentModel.class.php'; $commentModel = new commentModel(); // $commentModel->getComments('1'); $action = $_GET['action']; $blogId = $_REQUEST['blogId']; switch ($action) { case 'getComments': $result = $commentModel->getComments($blogId); echo json_encode($result); break; case 'addComment': $content = $_POST['content']; if (strlen($content) >= 10) { $result = $commentModel->addComment($blogId, $content); if ($result) { // require_once 'swiftmailer-master/lib/swift_required.php'; // $email = '*****@*****.**'; // //发送邮件,以QQ邮箱为例 // //配置邮件服务器,得到传输对象 // $transport=Swift_SmtpTransport::newInstance('smtp.qq.com',25); // //设置登陆帐号和密码 // $transport->setUsername('*****@*****.**'); // $transport->setPassword('songwanfu0531'); // //得到发送邮件对象Swift_Mailer对象 // $mailer=Swift_Mailer::newInstance($transport); // //得到邮件信息对象 // $msg=Swift_Message::newInstance(); // //设置管理员的信息 // $msg->setFrom(array('*****@*****.**'=>'Meet Better Me'));