当前位置: 首页>>代码示例>>PHP>>正文


PHP news::fetch方法代码示例

本文整理汇总了PHP中news::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP news::fetch方法的具体用法?PHP news::fetch怎么用?PHP news::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在news的用法示例。


在下文中一共展示了news::fetch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_latest_new

function get_latest_new()
{
    include '../model/news.php';
    $news = new news();
    $row = $news->latest_news();
    if (!$news) {
        echo '{"result": 0, "message": "No news"}';
        return;
    }
    echo '{"result": 1, "news": [';
    while ($row) {
        echo json_encode($row);
        $row = $news->fetch();
        if ($row) {
            echo ",";
        }
    }
    echo "]}";
    return;
}
开发者ID:salmgazer,项目名称:RealGalacticos,代码行数:20,代码来源:controller.php

示例2: process

 private function process()
 {
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     $mail = services::getService('mail');
     // lost password
     if ($params->getParam('lostpassword') == 'true') {
         $this->lostpassword = true;
         $this->pwform = new formLostPassword('LostPassword');
         if ($this->pwform->validate()) {
             // write email
             $user = new user();
             $user->email = $this->pwform->exportValue('email');
             if ($user->find(true)) {
                 $mail->send('lostpassword', $user, $user->password);
                 $user->password = crypt($user->password, 'dl');
                 $user->update();
                 $this->switchPage('home&msg=msg_pw_sent');
             } else {
                 $this->switchPage('home&lostpassword=true&msg=msg_no_email');
             }
         }
     } else {
         // newsscript: write news
         if ($params->getParam('news') == 'writenews') {
             $newsform = new formNewsData("newsdata");
             if ($newsform->validate()) {
                 $new_news = new news();
                 $new_news->name = convertNewsSubmits($newsform->exportValue('newsname'));
                 $new_news->abstract = convertNewsSubmits($newsform->exportValue('newsabstract'));
                 $new_news->text = convertNewsSubmits($newsform->exportValue('newstext'));
                 $new_news->date = time();
                 $new_news->lang = $newsform->exportValue('newslang');
                 $new_news->insert();
                 $newsform->freezeForm();
                 $this->addMsg('msg_news_submitted');
             }
             $this->newsform = $newsform;
         }
     }
     // newsscript: show news headlines
     $shownews = new news();
     $shownews->lang = $lang->getLang();
     $shownews->orderBy('date DESC');
     $shownews->find();
     while ($shownews->fetch()) {
         $this->shownews[] = array('name' => $shownews->name, 'abstract' => $shownews->abstract, 'text' => $shownews->text, 'date' => date('d. m. Y', $shownews->date), 'id' => $shownews->id);
     }
     // Instantiate the HTML_QuickForm object
     $this->login_form = new formLogin('LoginForm');
     // count resources and pools
     $pool_count = new pools();
     $res_count = new resources();
     $pool_count->wait = 0;
     $pool_count->find();
     $res_count->find();
     $this->pool_count = 0;
     while ($pool_count->fetch()) {
         ++$this->pool_count;
     }
     $this->res_count = 0;
     while ($res_count->fetch()) {
         ++$this->res_count;
     }
     // Try to validate a form
     if ($this->login_form->validate()) {
         if (loginCorrect($this->login_form->exportValue('login'), $this->login_form->exportValue('loginpassword'))) {
             $session = services::getService('pageParams');
             if ($this->login_form->exportValue('remember')) {
                 setcookie('login', $this->login_form->exportValue('login'), time() + 60 * 60 * 24 * 365);
                 setcookie('password', $this->login_form->exportValue('loginpassword'), time() + 60 * 60 * 24 * 365);
             } else {
                 $session->addParam('login', $this->login_form->exportValue('login'), 'session');
                 $session->addParam('password', $this->login_form->exportValue('loginpassword'), 'session');
             }
             $session->addParam('msg', 'msg_login_correct', 'page');
             $this->switchPage('mysite');
         } else {
             $this->addMsg('msg_login_wrong');
         }
     } else {
         if (isset($this->user)) {
             $this->switchPage('mysite');
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:cosmopool-multi-svn,代码行数:87,代码来源:pageHome.php


注:本文中的news::fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。