本文整理汇总了PHP中Pages::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Pages::update方法的具体用法?PHP Pages::update怎么用?PHP Pages::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pages
的用法示例。
在下文中一共展示了Pages::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateProcess
function updateProcess($id)
{
$send = Request::get('send');
$valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.content' => 'min:1', 'send.keywords' => 'slashes'));
if (!$valid) {
throw new Exception("Error Processing Request: " . Validator::getMessage());
}
$uploadMethod = Request::get('uploadMethod');
$loadData = Pages::get(array('where' => "where pageid='{$id}'"));
if (!isset($loadData[0]['pageid'])) {
throw new Exception("This page not exists.");
}
switch ($uploadMethod) {
case 'frompc':
if (Request::hasFile('imageFromPC')) {
if (Request::isImage('imageFromPC')) {
$send['image'] = File::upload('imageFromPC');
File::remove($loadData[0]['image']);
}
}
break;
case 'fromurl':
if (Request::isImage('imageFromUrl')) {
$url = Request::get('imageFromUrl');
$send['image'] = File::upload('uploadFromUrl');
File::remove($loadData[0]['image']);
}
break;
}
if (!Pages::update($id, $send)) {
throw new Exception("Error. " . Database::$error);
}
}
示例2: edit
public function edit($id)
{
// find page
if (($page = Pages::find(array('id' => $id))) === false) {
return Response::redirect($this->admin_url . '/pages');
}
// process post request
if (Input::method() == 'POST') {
if (Pages::update($id)) {
// redirect path
return Response::redirect($this->admin_url . '/pages/edit/' . $id);
}
}
Template::render('pages/edit', array('page' => $page));
}
示例3: editAction
function editAction()
{
$this->view->title = "Edit pages";
$pages = new Pages();
if ($this->_request->isPost()) {
Zend_Loader::loadClass('Zend_Filter_StripTags');
$filter = new Zend_Filter_StripTags();
$this->view->headScript()->appendFile('/js/tiny_mce/tiny_mce.js', 'text/javascript');
$id = (int) $this->_request->getPost('id');
$name = $filter->filter($this->_request->getPost('name'));
$name = trim($name);
$body = $filter->filter($this->_request->getPost('body'));
$body = trim($body);
$title = trim($filter->filter($this->_request->getPost('title')));
if ($id !== false) {
if ($name != '' && $body != '' && $title != '') {
$data = array('name' => $name, 'body' => $body, 'title' => $title);
$where = 'id = ' . $id;
$pages->update($data, $where);
$this->_redirect('/admin');
return;
} else {
$this->view->pages = $pages->fetchRow('id=' . $id);
}
}
} else {
// pages id should be $params['$id']
$id = (int) $this->_request->getParam('id', 0);
if ($id > 0) {
$this->view->pages = $pages->fetchRow('id=' . $id);
}
}
// additional view fields required by form
$this->view->action = 'edit';
$this->view->buttonText = 'Update';
}
示例4: update
/**
* Updates Pages into database.
*
* @param Pages $pages
* @param array $input
*
* @return Pages
*/
public function update($pages, $input)
{
$input['url'] = Quarx::convertToURL($input['url']);
$input['is_published'] = isset($input['is_published']) ? (bool) $input['is_published'] : 0;
$input['published_at'] = isset($input['published_at']) && !empty($input['published_at']) ? $input['published_at'] : Carbon::now()->format('Y-m-d h:i:s');
return $pages->update($input);
}