当前位置: 首页>>代码示例>>PHP>>正文


PHP Mapper::save方法代码示例

本文整理汇总了PHP中Mapper::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapper::save方法的具体用法?PHP Mapper::save怎么用?PHP Mapper::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mapper的用法示例。


在下文中一共展示了Mapper::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 function save(Feed $feed)
 {
     parent::save($feed);
     foreach ($feed->items() as $item) {
         $item->feed_id($feed->id());
         $item->save();
     }
 }
开发者ID:nitewol,项目名称:reader,代码行数:8,代码来源:feedmapper.php

示例2: index

 function index()
 {
     if (!empty($_POST)) {
         $check = new Check();
         if (!empty($_FILES["img"]["name"])) {
             $target_dir = "uploads/";
             $target_file = $target_dir . basename($_FILES["img"]["name"]);
             $filename = $check->checkInput($_FILES['img']['name']);
             $filesize = filesize($target_file);
             move_uploaded_file($_FILES["img"]["tmp_name"], $target_file);
         } else {
             $filename = '';
             $filesize = '';
         }
         //Получаем данные методом пост
         $name = $check->checkInput($_POST['name']);
         $surname = $check->checkInput($_POST['surname']);
         $email = $check->checkInput($_POST['email']);
         $login = $check->checkInput($_POST['login']);
         $pass = $check->checkInput($_POST['pass']);
         $confirmpass = $check->checkInput($_POST['confirmpass']);
         $age = $check->checkInput($_POST['age']);
         //Создаем массив для валидации данных
         $validateArr = array('name' => $name, 'surname' => $surname, 'email' => $email, 'login' => $login, 'password' => $pass, 'confirmpass' => $confirmpass, 'age' => $age, 'filename' => $filename, 'filesize' => $filesize);
         $pdo = new Db();
         //класс с конфигурацией базы данных
         $db = $pdo->get();
         $validate = new Validate($db);
         $errors = $validate->getErrors($validateArr);
         //Выявляем ошибки через валидатор
         if (empty($errors)) {
             try {
                 //Сохраняем пользователя посредством паттерна Data Mapper
                 $user = new User();
                 $user->name = $name;
                 $user->surname = $surname;
                 $user->email = $email;
                 $user->login = $login;
                 $user->password = md5($pass);
                 $user->age = $age;
                 $user->filename = $filename;
                 $mapper = new Mapper($db);
                 $mapper->save($user);
                 $this->user = $mapper->select($user);
                 $this->out('profile.php');
             } catch (Exception $e) {
                 echo "Ошибка загрузки данных <br>" . $e->getMessage();
             }
         } else {
             foreach ($errors as $error) {
                 $this->error = $error . "<br>";
             }
             $this->out('register.php');
         }
     } else {
         $this->out('register.php');
     }
 }
开发者ID:toppestkek,项目名称:Test,代码行数:58,代码来源:ctrlIndex.php

示例3: log

 public static function log($message)
 {
     $logEntry = new \Bh\Entity\LogEntry($message);
     Mapper::save($logEntry);
     Mapper::commit();
 }
开发者ID:uglybob,项目名称:bh.net,代码行数:6,代码来源:Log.php

示例4: function

$app->get('/add', function () use($app) {
    $main = '';
    $add = 'active';
    return $app['twig']->render('add.twig', array('main' => $main, 'add' => $add));
});
$app->post('/add', function () use($app) {
    if (isset($_POST)) {
        $check = new Check();
        $name = $check->checkInput($_POST['name']);
        $comment = $check->checkInput($_POST['comment']);
        $pdo = new Db();
        $db = $pdo->get();
        $validate = new Validate($db);
        $data = array('name' => $name, 'comment' => $comment);
        $errors = $validate->getErrors($data);
        if (!empty($errors)) {
            $main = '';
            $add = 'active';
            return $app['twig']->render('add.twig', array('main' => $main, 'add' => $add, 'errors' => $errors, 'name' => $name, 'comment' => $comment));
        } else {
            $mapper = new Mapper($db);
            $ip_address = $_SERVER['REMOTE_ADDR'];
            $comments = new Comments();
            $comments->name = $name;
            $comments->comment = $comment;
            $comments->ip_address = $ip_address;
            $mapper->save($comments);
            return $app->redirect('/GuestBook/');
        }
    }
});
开发者ID:toppestkek,项目名称:GuestBook,代码行数:31,代码来源:add.php


注:本文中的Mapper::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。