Поделитесь для вашей справки, как показано ниже:
Входной файл. Индекс имени файла. PHP
Имя файла конфигурации config.php
'Configuration value' 'SHOW_PAGE_TRACE'=>true, 'DB_TYPE'=>'mysqli', //database type 'DB_HOST'=>'127.0.0.1', //server address 'DB_NAME'=>'msg', //database name 'DB_USER'=>'root', //username 'DB_PWD'=>'root', //password 'DB_PORT'=>'3306', //port 'DB_PREFIX'=>'ms_', //database table prefix );
Имя Файла Контроллера Msg Controller. класс. PHP
order('id DESC')->select();
$this->assign('info',$info);
$this->display();
}
public function sendMsg(){
$msg = new \Home\Model\MsgModel();
if (!empty($_POST)){
$data = $msg->create();
if($data){
$data['user_hobby'] = implode(',',$data['user_hobby']);
$z = $msg->add($data);
if ($z){
$this->redirect('Msg/sendMsg');
}
}else{
$this->assign('errorInfo',$msg->getError());
}
}
$this->display();
}
public function upd($id){
$msg = D('Msg');
if (!empty($_POST)){
$z = $msg->save($_POST);
if ($z){
$this - > redirect ('index', array (), 2,'modified successfully');
}else{
$this - > redirect ('upd', array ('id'=> $id), 2,'modification failed');
}
}else{
$info = $msg->find($id);
$this->assign('info',$info);
$this->display();
}
}
public function addMsg(){
$msg = D('Msg');
if (!empty($_POST)){
$z = $msg->add($_POST);
if ($z){
$this - > redirect ('index', array (), 2,'add success');
}else{
$this - > redirect ('addMsg', array (), 2,'add failure');
}
}else{
$this->display();
}
}
public function del($id){
if(D('Msg')->delete($id)){
$this->success('成功',U('index'),2);
}else{
This - > error ('failure', U ('index'), 2);
}
}
}Имя файла Шаблона Модель Msg. класс. PHP
Просмотр: Имя файла добавить Msg. HTML
Title
Просмотр: Индекс имени файла. HTML
Message List--HoverTree h2> message listadd < tr > < td > message time: < td > < td > {$vo.update_time | date= "Y-m-d H:i:s", #} < tr > < td > message: < / td > < td > < td > {$vo.user} < / td > < / TR > < tr > < td > Title: < td > < td > {$vo.title} < tr > < td > Content: < td > < td > {$vo.msg} < tr > < td > reply: < td > < td > {vo.replay}
modify delete HoverTree © 2014 keleyi.com.
Просмотр: Имя файла sendMsg. HTML
Title
Просмотреть имя файла upd.html
Title
структура каталогов
Инструкция SQL базы данных
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */; /*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */; /*!40101 SET @[email protected]@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- - Database: `msg` -- -- -------------------------------------------------------- -- The structure of the table `ms_msg'` -- CREATE TABLE IF NOT EXISTS `ms_msg` ( ` ID `int(10) NOT NULL AUTO_INCREMENT COMMENT'Primary Key', ` admin_user `varchar (100) NOT NULL COMMENT'Administrator', ` update_time `int(10) NOT NULL COMMENT'update time', ` status `int (2) NOT NULL COMMENT'status', ` send_msg_time `int(10) NOT NULL COMMENT'Message Time', ` User `varchar (100) NOT NULL COMMENT'Speaker', ` Title `varchar (100) NOT NULL COMMENT'Title', ` MSG `varchar (200) NOT NULL COMMENT'Content', ` Reply `varchar (200) NOT NULL COMMENT'Reply', PRIMARY KEY (`id`) ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COMMENT ='Message Table'AUTO_INCREMENT = 19; -- - Data `ms_msg'in the dump table` -- INSERT INTO `ms_msg` (`id`, `admin_user`, `update_time`, `status`, `send_msg_time`, `user`, `title`, `msg`, `replay`) VALUES (1,'ms', 1479449110, 1, 1479449110,'1','Lax's weight loss','the other subject','NULL'), (7, '', 321423432, 0, 0, 'kljflwk', 'kjsdfnlk', 'nlkdsjfn', 'kljnf'), (3,'ms', 1479451017, 1, 1479451017,'1','easy to happen to me','Volvo Fly','NULL') (8, 'ms', 1479544687, 1, 1479544687, '', 'qwe', '', 'NULL'), (9, 'ms', 1479544693, 1, 1479544693, 'qwe', 'qwe', 'qwe', 'NULL'), (10, 'ms', 1479544970, 1, 1479544970, 'qwe', 'qwe', 'qwe', 'NULL'), (11, 'ms', 1479544979, 1, 1479544979, '12', '12', '12', 'NULL'), (12, 'ms', 1479545029, 1, 1479545029, '12', '12', '12', 'NULL'), (13, 'ms', 1479546357, 1, 1479546357, '12', '12', '12', 'NULL'), (14, 'ms', 1479547163, 1, 1479547163, '12', '12', '12', 'NULL'), (16, 'ms', 1479547667, 1, 1479547667, '12', '12', '123', 'NULL'), (17,'ms', 2147483647, 1, 1479547682,'up to Kunming 3','said payment','Blue Mountain Coffee','123213'); /*!40101 SET [email protected]_CHARACTER_SET_CLIENT */; /*!40101 SET [email protected]_CHARACTER_SET_RESULTS */; /*!40101 SET [email protected]_COLLATION_CONNECTION */;
Читатели, интересующиеся контентом, связанным с ThinkPHP, могут ознакомиться с темами этого сайта: Введение в ThinkPHP, Краткое описание навыков работы с шаблонами ThinkPHP, Краткое описание общих методов ThinkPHP, Введение в CodeIgniter, Введение в рабочую среду Zend Framework и Краткое описание технологии шаблонов PHP.
Я надеюсь, что эта статья будет полезна для разработки PHP-программы на основе платформы ThinkPHP.