882 篇
建站知识总结与分享
搜索“php”
php删除第一个字符,最后一个字符
web 0 0
2062 0 2021-02-02 PHP
循环拼接字符串的时候,会出现多一个间隔符的问题,怎么删除? 代码: $str = ''; foreach($resourcePath as $vo){ $str .= ',' . $vo["$field"]; } $resourcePath = ltrim($str, ",...
thinkphp5.1利用$.post操作返回variable type error: array错误
taotaoit 0 0
2359 0 2021-01-31 ThinkPHP5.1
代码如下: /** * 清除服务器缓存 */ function clearAll() { var url = '{:url("admin/index/clearAll")}'; $.post(url,{},function(data,textStatus){ if(data.sta...
thinkphp5.1 跨模型调用
taotaoit 0 0
1781 0 2021-01-27 ThinkPHP5.1
模型调用另一个模型时,如果是在同一个命名空间下,是不需要引入模型,可以直接使用。命名空间,相当于是当前目录。 示例: $configlist = Config::where($where_config) ->order(['dataSort','configId']) ->select(); 或者调用另一个模型...
thinkphp5.1模板中使用switch
web 0 0
2600 0 2021-01-27 ThinkPHP5.1
用法: {switch 变量 } {case value1 }输出内容1{/case} {case value2}输出内容2{/case} {default /}默认情况 {/switch} 示例: {switch User.level} {case 1}value1{/case} {c...
thinkphp where concat
web 0 0
2451 0 2021-01-23 ThinkPHP5.1
thinkphp5.1中where条件数据库字段保存为逗号隔开,查询的时候使用concat 数据库中关键字存储的是"a,ab,abc"类似信息,当搜索"a"的时候,我只想要关键字包含"a"的信息,不需要包含"ab"或"abc"的信息,怎么实现呢? 需要在字段值两端加,变成",a,ab,abc,",然后搜索关键字两端加,变成...
thinkphp5查询只需要某一列(某一个字段,其他不需要)的值
web 0 0
4153 0 2021-01-23 ThinkPHP5.1
查询某一列的值可以用 // 返回数组 Db::table('think_user')->where('status',1)->column('name'); // 指定id字段的值作为索引 Db::table('think_user')->where('status',1)->column('name','i...
Thinkphp调用Image类生成等比例缩略图$image->thumb
taotaoit 1 0
3059 0 2021-01-13 ThinkPHP
图片类extend\image\Image.php /** * 生成缩略图 * * @param integer $width 缩略图最大宽度 * @param integer $height 缩略图最大高度 * @param int $type 缩略图裁剪类型...
PHP time():获取当前时间戳
web 0 0
2037 0 2021-01-12 PHP
使用 time() 函数获取当前时间戳。 <?php $time = time(); echo '当前的时间戳为:'.$time.'<br>'; date_default_timezone_set('GMT'); $time = time(); echo '将时区设置为零时...
Thinkphp5模板输出,时间戳自动转换为时间格式
web 0 0
2886 0 2021-01-12 ThinkPHP5.1
// 自动写入时间戳字段 'auto_timestamp' => true, // 时间字段取出后的默认时间格式 'datetime_format' => 'Y-m-d H:i:s', thinkphp5数据库存储时间为时间戳,模板输出时不需要时间格式化就可以输出时间格式 {$vo.create_...
thinkphp5获取新增记录id
web 0 0
2492 0 2021-01-11 ThinkPHP5.1
使用getLastInsID方法: Db::name('messege')->insert($data); $userId = Db::name('messege')->getLastInsID(); 使用insertGetId方法 $userId = Db::name('messege')->insertGetId(...
tp5 model 关闭时间戳自动写入
web 0 0
2393 0 2021-01-05 ThinkPHP5.1
模型里面设置: protected $autoWriteTimestamp = false; // 关闭自动写入时间戳 protected $updateTime = false;// 只关闭自动写入update_time字段 在config中添加全局设置: 'auto_timestamp' => false,&emsp...
thinkphp5 unique自动验证账号已存在,数据表默认主键是id
taotaoit 2 0
3059 0 2021-01-04 ThinkPHP5.1
thinkphp5 使用unique自动验证账号是否已存在,好像数据表默认主键必须是id 如果主键不是id,会提示错误SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'field list' 解决办法,可以自定义主键id ...
Thinkphp5清除runtime下的cache缓存,temp缓存,log缓存
web 0 0
3095 0 2020-12-30 ThinkPHP5.1
Thinkphp5清除runtime下的cache缓存,temp缓存,log缓存 /** * 清除缓存 */ public function clearCache(){ \think\facade\Cache::clear(); return ZHTReturn('清除成功',1); } /...
thinkphp5.1 env
taotaoit 0 0
1923 0 2020-12-30 ThinkPHP5.1
$path = env(); dump($path); array(11) { ["THINK_PATH"] => string(26) "D:\www\WWW\maiqi\thinkphp\" ["ROOT_PATH"] => string(17) "D:\www\WWW\maiqi\" ["APP_PATH"...
thinkphp5.1 关闭日志log和日志设置
taotaoit 0 0
4857 0 2020-12-30 ThinkPHP5.1
打开文件config\log.php // +---------------------------------------------------------------------- // | 日志设置 // +----------------------------------------------------------...
thinkphp5.1中使用缓存和清除缓存
taotaoit 0 0
2630 0 2020-12-30 ThinkPHP5.1
使用缓存 public function pageQuery(){ $rs = cache('role'); if(!$rs){ $key = input('key'); $where[] = ['status','=',1]; if($key != '')$where[] = ['roleTitle','...
关于本站

“最难不过坚持”

本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作

有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339

8308404 2698 39
最新评论
https://jueru.net/
评 留言
:weixiao:
评 留言
:shuijiao: :weiqu: :zhenbang: :leng:
评 留言
:yiwen: :yiwen: :yiwen: :yiwen:
评 EasySass: could not generate CSS file. See Output panel for details.
这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
评 TP6模型事件-查询后onAfterRead不好用
文章标签更多
ThinkPHP (260)
Mysql (59)
DedeCms (33)
jQuery (74)
证件照 (1)
setInc (4)
setDec (4)
onclick (5)