![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
TP笔记
文章平均质量分 70
fss_2352758323
个人简介
30天内还可以编辑 5 次
展开
-
PHP TP5 连接postgres数据库,获取新增数据主键值
TP5 文档中::说明:新增数据,如果要获取新增数据的自增ID 1. 使用Model,可以使用下面的方式:$user = new User;$user->name = 'thinkphp';$user->email = 'thinkphp@qq.com';$user->save();// 获取自增IDecho $user->id;原创 2017-07-28 23:51:38 · 2368 阅读 · 0 评论 -
PHP day6 DB数据库操作
1. 数据库连接配置 public function index() { //方式一,在cong里配置database //dump(config('database')); //$res = Db::connect(); //方式二、给connect()方法将配置以数组进行传递 /*$res = Db原创 2017-07-25 14:37:23 · 364 阅读 · 0 评论 -
PHP day7 TP5 model模型对象
1. tp 模型对象 查询数据 //一,获取一条数据 //1.传递闭包函数 /*$res = User::get(function($query){ $query->where('username','eq','user002') ->field('username,email');原创 2017-07-25 14:40:44 · 1400 阅读 · 0 评论 -
PHP day8 TP5 model更新,软删除
1. 模型时间戳 一般不开启database配置文件 里的'aotu_timestamp =true' 而可以在model里单独开启,可以如下开启时间戳的功能 public class User{ protected $autoWriteTimestamp = true;} 注意protected $autoWriteTimes原创 2017-07-25 14:44:14 · 1496 阅读 · 0 评论 -
PHP tp5 使用,连接 postgres 问题
一、 获取系统常量信息:var_dump(get_defined_constants(true)); //若参数为true则分类显示 二、 连接 postgres 问题问题一: 配置修改为pgsql,提示could not find driver1. tp5 下database 配置 'DB_TYPE' => 'pgsql', 2. 打原创 2017-07-25 14:50:22 · 4250 阅读 · 0 评论 -
PHP day9 TP post接受数据 variable type error:array
request:前台提交的参数 'user' => array (size=2) 'loginname' => string 'user001' (length=7) 'password' => string '132456' (length=6) 'validateCode' => string '321654' (l原创 2017-07-25 14:55:36 · 1741 阅读 · 0 评论 -
PHP TP5 省市区表多级关联模型查询,和db方式查询封装效率
需要对省市区 三张表进行查询,将查询结果 进行组装成如下格式,便于前段js调用array (size=34) 1 => array (size=4) 'id' => int 1 'name' => string '北京市' (length=9) 'code' => string '110000' (length=6) 'cities原创 2017-07-25 15:31:34 · 4821 阅读 · 0 评论 -
PHP TP5 使用getPk()注意,在模型关联时,最好把主键名参数写上
1.getPk 会把primary的键都查询出来2.使用模型关联时,最好把主键名参数写上如题:使用模型关联时,最好把主键名参数写上使用的是 TP5.0.9在 Model 中设置 表1 订单表 一对多关联 表2 订单详细申请项表表1. Applyorder 订单表<?phpnamespace app\common\model;use think\Mod原创 2017-08-04 14:59:02 · 6428 阅读 · 0 评论