function find($id) { $row = parent::find($id); if ($row) { $row['user_password'] = $GLOBALS['auth']->encoder->Decrypt_Text($row['user_password']); } return $row; }
<div class="nav"> <a href="manage.php"> <label>新闻列表</label> </a> <a href="add.php"> <label>添加新闻</label> </a> <label class="active">编辑新闻</label> </div> </div> <!-- 导航结束 --> <!-- 表单 --> <?php require "../model/model.php"; $news = new model("news"); $item = $news->find($_GET['id']); ?> <div class="publish"> <form action="../controller/edit.php" method="post" enctype="multipart/form-data"> <input name="id" value="<?php echo $_GET['id']; ?> " hidden> <div class="item">标题: <div class="input"> <input name="title" value="<?php echo $item->title; ?> "> </div> </div>
/** * 根据post请求内容填充多个model并存入数组中 * @return array 模型集合 */ public function load_all_from_post() { $prevstr = $this->YYUCSYS_tablename . 'T'; $begin = strlen($prevstr); $begin2 = strlen($prevstr) + 32; //定义存储提交信息的数组 $posts = array(); if (get_magic_quotes_gpc()) { foreach ($_POST as $k => $v) { if (strpos($k, $prevstr) === 0) { $uuid = substr($k, $begin, 32); $field = substr($k, $begin2); if (!isset($posts[$uuid])) { $posts[$uuid] = array(); } if (is_array($v)) { $v = ',' . implode(',', $v) . ','; } $posts[$uuid][$field] = stripslashes($v); } } } else { foreach ($_POST as $k => $v) { if (strpos($k, $prevstr) === 0) { $uuid = substr($k, $begin, 32); $field = substr($k, $begin2); if (!isset($posts[$uuid])) { $posts[$uuid] = array(); } if (is_array($v)) { $v = ',' . implode(',', $v) . ','; } $posts[$uuid][$field] = $v; } } } //填充实体 $models = array(); foreach ($posts as $k => $post) { if (!$this->YYUCSYS_isorgin) { $mod = new $this->YYUCSYS_tablename(k); } else { $mod = new model($this->YYUCSYS_tablename, k); } if (!empty($post['id']) && isset($this->YYUCSYS_db)) { $mod->find($post['id']); } foreach ($post as $kk => $vv) { $mod->{$kk} = $vv; } if (!$this->YYUCSYS_isorgin) { $mod->fill_entity_field(); } $models[] = $mod; } return $models; }
/** * @param $id * @param array $columns * @return mixed */ public function Find($id, $columns = array('*')) { return $this->_model->find($id, $columns); }