thinkphp学习记录
2016-04-12 10:57
471 查看
一、关联模型(参数详解)
'mapping_type'=>self::HAS_ONE,
'class_name'=>'Card',//可不写
'mapping_name'=>'card',// 展示时Card改为card
'foreign_key'=>'uid', //外键
'mapping_fields'=>'code',//单独获取该键值
'as_fields'=>'code:mycode',//单独作为一个参数加入到主表中展示,":"后为变量名冲突时做修改
'condition'=>'id=1',//条件
二、多表查询+模糊查询示例
$data=$comment->join('user_table ON user_table.user_id=comment.user_id')->join('theme ON theme.theme_id=comment.theme_id')->field('comment.id,user_table.user_id,user_table.user_name,theme.theme_name,comment.content,comment.create_time')->limit($page,8)->where('user_table.user_name
like "%'.$searchkey.'%" or theme.theme_name like "%'.$searchkey.'%"')->select();
'mapping_type'=>self::HAS_ONE,
'class_name'=>'Card',//可不写
'mapping_name'=>'card',// 展示时Card改为card
'foreign_key'=>'uid', //外键
'mapping_fields'=>'code',//单独获取该键值
'as_fields'=>'code:mycode',//单独作为一个参数加入到主表中展示,":"后为变量名冲突时做修改
'condition'=>'id=1',//条件
二、多表查询+模糊查询示例
$data=$comment->join('user_table ON user_table.user_id=comment.user_id')->join('theme ON theme.theme_id=comment.theme_id')->field('comment.id,user_table.user_id,user_table.user_name,theme.theme_name,comment.content,comment.create_time')->limit($page,8)->where('user_table.user_name
like "%'.$searchkey.'%" or theme.theme_name like "%'.$searchkey.'%"')->select();
相关文章推荐
- JS循环PHP数组
- 本地配置环境打开项目出现404/本地wampserver配置伪静态以及php.ini配置
- mac下thinkphp验证码问题
- php7性能、兼容性和稳定性探讨
- 百钱买百鸡问题 php版本
- laravel5的Bcrypt加密方式对系统保存密码的小结
- 关于在win7系统下zend studio5.5.0启动闪退问题的解决
- php 判断文件/目录是否存的方法
- 如何用PHPExcel读取超大excel文件
- PHP中双引号和单引号的区别
- 解除php文件大小限制
- 每天laravel-20160711|Event-2
- php面向对象-关键字的合理运用,public,private,
- Zend Studio / Ecliplse插件EasyExplorer,打开资源文件所在的文件夹
- php绘制图片验证码
- PhpExcel中文帮助手册|PhpExcel使用方法
- PHP自动加载实用技巧
- PHPExcel导出excel 复制代码
- ThinkPHP之__construct()和__initialize()
- 深入理解PHP Opcode缓存原理