本文整理汇总了PHP中Blog::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Blog::add方法的具体用法?PHP Blog::add怎么用?PHP Blog::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blog
的用法示例。
在下文中一共展示了Blog::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: blog_handler
function blog_handler()
{
$this->check_login();
$params = $this->input->post();
if (isset($params['save'])) {
Blog::add($params);
}
redirect('admin/blogs');
}
示例2: add
public function add()
{
//モデルを呼び出す
$blog = new Blog();
$this->addOptions = $blog->add();
//アクション名を指定
$this->action = 'add';
//ビューを呼び出す
require 'views/layout/application.php';
}
示例3: create
public function create($query)
{
$params = array('message' => null);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$blog = new Blog();
$blog->setFields($_POST);
if ($blog->add()) {
$params['message'] = 'Record added successfully';
} else {
$params['message'] = 'Request was not successfull. Please try again';
$params['error'] = true;
}
}
$this->setParams('params', $params);
$this->render();
}
示例4: array
} else {
send_to_notify("error", 19);
}
}
break;
case "add_article":
case "mod_article":
//data
$data = array("head" => $_POST["head"], "subh" => $_POST["subh"], "body" => $_POST["body"]);
//meta-data
$allow_comments = $_POST["allow_comments"] == "on" ? 1 : 0;
$published = $_POST["published"] == "on" ? 1 : 0;
$meta_data = array("tags" => $_POST["tags"], "author" => $_POST["author"], "allow_comments" => $allow_comments, "published" => $published);
$blog = new Blog();
if ($_GET["action"] == "add_article") {
$id = $blog->add($data);
if ($id) {
$add_meta = $blog->add_meta($id, $meta_data);
}
//send ->
if ($add_meta) {
if ($GLOBALS["enable_logging"] == true) {
add_to_log($_SESSION["admin_user"], "Created Article {$head}");
}
send_to_notify("success", 2);
} else {
send_to_notify("error", 20);
}
} else {
if ($_GET["action"] == "mod_article") {
$id = $_GET["id"];
示例5: testsperengine
//.........这里部分代码省略.........
SmartTest::instance()->testPack = "unassociate by deleting a bean?";
$anotherdrink = RedBean_OODB::dispense("whisky");
$anotherdrink->name = "bowmore";
$anotherdrink->age = 18;
$anotherdrink->singlemalt = 'y';
RedBean_OODB::set($anotherdrink);
RedBean_OODB::associate($anotherdrink, $john);
$hisdrinks = RedBean_OODB::getAssoc($john, "whisky");
if (count($hisdrinks) !== 1) {
SmartTest::failedTest();
}
RedBean_OODB::trash($anotherdrink);
$hisdrinks = RedBean_OODB::getAssoc($john, "whisky");
if (count($hisdrinks) !== 0) {
SmartTest::failedTest();
}
SmartTest::instance()->progress();
SmartTest::instance()->testPack = "create parent child relationships?";
$pete = RedBean_OODB::dispense("person");
$pete->age = 48;
$pete->gender = "m";
$pete->name = "Pete";
$peteid = RedBean_OODB::set($pete);
$rob = RedBean_OODB::dispense("person");
$rob->age = 19;
$rob->name = "Rob";
$rob->gender = "m";
$saskia = RedBean_OODB::dispense("person");
$saskia->age = 20;
$saskia->name = "Saskia";
$saskia->gender = "f";
RedBean_OODB::set($saskia);
RedBean_OODB::set($rob);
RedBean_OODB::addChild($pete, $rob);
RedBean_OODB::addChild($pete, $saskia);
$children = RedBean_OODB::getChildren($pete);
$names = 0;
if (is_array($children) && count($children) === 2) {
foreach ($children as $child) {
if ($child->name === "Rob") {
$names++;
}
if ($child->name === "Saskia") {
$names++;
}
}
}
if (!$names) {
SmartTest::failedTest();
}
$daddies = RedBean_OODB::getParent($saskia);
$daddy = array_pop($daddies);
if ($daddy->name === "Pete") {
$ok = 1;
} else {
$ok = 0;
}
if (!$ok) {
SmartTest::failedTest();
}
SmartTest::instance()->progress();
SmartTest::instance()->testPack = "remove a child from a parent-child tree?";
RedBean_OODB::removeChild($daddy, $saskia);
$children = RedBean_OODB::getChildren($pete);
$ok = 0;
if (count($children) === 1) {
示例6: Blog
}
SmartTest::instance()->canwe = "countRelated";
R::gen("Blog,Comment");
$blog = new Blog();
$blog2 = new Blog();
$blog->setTitle("blog1");
$blog2->setTitle("blog2");
for ($i = 0; $i < 5; $i++) {
$comment = new Comment();
$comment->setText("comment no. {$i} ");
$blog->add($comment);
}
for ($i = 0; $i < 3; $i++) {
$comment = new Comment();
$comment->setText("comment no. {$i} ");
$blog2->add($comment);
}
if ($blog->numofComment() !== 5) {
die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
} else {
SmartTest::instance()->progress();
}
if ($blog2->numofComment() !== 3) {
die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
} else {
SmartTest::instance()->progress();
}
SmartTest::instance()->canwe = "associate tables of the same name";
$blog = new Blog();
$blogb = new Blog();
$blog->title = 'blog a';