本文整理汇总了PHP中Articles::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::update方法的具体用法?PHP Articles::update怎么用?PHP Articles::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionModified
/**
* 提交信息
*/
public function actionModified()
{
$data = $this->Common->getFilter($_POST);
$aid = (int) $data['aid'];
$article = $data['aritcle'];
$content = $data['a_content'];
$Articles = new Articles();
$ArticlesContent = new ArticlesContent();
if ($aid == 0) {
$article['add_date'] = $this->Common->getDate();
$content['aid'] = $Articles->insert($article);
$ArticlesContent->insert($content);
$article['aid'] = $content['aid'];
} else {
$where = array('aid' => $aid);
$Articles->update($article, $where);
$count = $ArticlesContent->getCount('*', $where);
if ($count > 0) {
$ArticlesContent->update($content, $where);
} else {
$content['aid'] = $aid;
$ArticlesContent->insert($content);
}
}
$this->jumpBox('成功!', Wave::app()->homeUrl . 'articles', 1);
}
示例2:
<?php
//We admit that Authors & Articles classes and their tables exist
//Get the article with id 1
$myArticle = Articles::getById(1);
//Check if character is found
if (!empty($myArticle)) {
//Get the new author to link to the article
$myAuthor = Authors::getById(2);
if (!empty($myAuthor)) {
//Update the "author" field of the article
$myArticle->prop('author', $myAuthor);
//And save the changes!
Articles::update($myArticle);
} else {
echo 'The new author of the article is not found.';
}
} else {
echo 'The article to update is not found.';
}
示例3: Articles
<?php
include "Mapper.php";
include "MapperCollection.php";
include "Articles.php";
$map = new Articles("articles");
// Find
echo "Find\n";
$result = $map->find(2);
print_r($result);
// insert
echo "\nInsert\n";
$obj = new stdClass();
$obj->name = "Ny artikel";
$obj->body = "Blah blah yada yada";
$obj->author_id = 2;
$map->insert($obj);
echo "Inserted object:\n";
print_r($obj);
echo "delete\n";
$map->delete($obj);
//update
echo "\nUpdate:\n";
$result->name = "Modified";
$map->update($result);