Пример #1
0
 /**
  * 提交信息
  */
 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
0
<?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
0
<?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);