Blogger Information
Blog 42
fans 0
comment 0
visits 15318
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0826 安装 配置thinkphp ,数据库操作:增删查改
小言
Original
269 people have browsed it

1.安装thinkphp,通过composer 方法进行全新安装

  1. 安装thinkphp
  2. composer create-project topthink/think tp
  3. 检查更新 thinkphp
  4. composer update

2.配置thinkphp

数据库连接

3.增删查改

首选引入Db门面类

  1. use think\facade\Db;

3.1查询单数据 ,使用find 方法

  1. $ret = Db::table('oyk_user')->where('uid',2)->find();
  2. print_r($ret);

3.2修改一条数据 ,update 方法

  1. $data = [
  2. 'password' => md5('phpcn'),
  3. 'last_time' => time()
  4. ];
  5. $ret = Db::table('oyk_user')->where('uid',8)->update($data);
  6. print_r($ret);

3.3删除一条数据 ,delete方法

  1. $ret = Db::table('oyk_user')->where('uid',8)->delete();
  2. print_r($ret);

3.4增加一条数据 ,insert方法

  1. $data = [
  2. 'nickname' => '小编1',
  3. 'phone' => '15888888888',
  4. 'password' => md5(123456),
  5. 'add_time' => time(),
  6. 'last_time' => time()
  7. ];
  8. $ret = Db::table('oyk_user')->insert($data);
  9. print_r($ret);
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!