本文整理汇总了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;
}
示例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');
}
}
}