Example #1
0
 public static final function getLastUser()
 {
     $c = self::getCookieValues();
     if (!$c || !class_exists($c['type'], true) || !is_subclass_of($c['type'], 'UserModel') || !($user = Model::getById($c['id'], $c['type'])) || !$user instanceof self || $user->getHash() != $c['hash']) {
         return null;
     }
     return $user;
 }
Example #2
0
 public function type_edit()
 {
     $id = I('id', NULL);
     if (!empty($id)) {
         $model = new Model('kefu_type');
         $data = $model->getById($id);
         $this->assign('udata', $data);
     }
     $this->display();
 }
Example #3
0
 public static function __fromDbValue($value, $type = null)
 {
     return $value && $type ? Model::getById($value, $type) : null;
 }
Example #4
0
 public static function getById($id)
 {
     return Model::getById($id);
 }
<?php

require_once 'connection.php';
require_once 'models/model.php';
$q = $_GET['q'];
// setting up connection to database
$url = parse_url($_SERVER['REQUEST_URI']);
$id = $url['query'];
$conn = getConnection();
$model = new Model($conn);
$match = $model->getById($id)[0];
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Paw to Heart</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/more-info.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <link rel="shortcut icon" href="data/logo2.png">
</head>
<body>
    <?php 
include 'views/menu.php';
?>
    <div class="container">
        <div class="row pet-container">
Example #6
0
 public function getById($id)
 {
     return parent::getById($id);
 }
 /**
 +----------------------------------------------------------
 * 更新一个数据对象
 +----------------------------------------------------------
 * @access protected 
 +----------------------------------------------------------
 * @param Model $model 数据对象 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 protected function _update($model)
 {
     $vo = $model->create('', 'edit');
     if (!$vo) {
         $this->error($model->getError());
     }
     $id = is_array($vo) ? $vo[$model->getPk()] : $vo->{$model->getPk()};
     $guid = $model->getModelName() . '_' . $id;
     if (S($guid) == $vo) {
         $this->error(L('无需更新!'));
     }
     $result = $model->save($vo);
     if ($result) {
         $vo = $model->getById($id);
         // 保存成功,更新缓存Vo对象
         S($guid, $vo);
         //数据保存触发器
         if (method_exists($this, '_trigger')) {
             $this->_trigger($vo);
         }
         if (!empty($_FILES)) {
             //如果有文件上传
             //执行默认上传操作
             //保存附件信息到数据库
             $this->_upload(MODULE_NAME, $id);
         }
         //成功提示
         $this->success(L('_UPDATE_SUCCESS_'));
     } else {
         //错误提示
         $this->error($model->getError());
     }
 }