thinkphp学习过程中遇到的问题

a标签带值跳转到controller层,找不到数据

Array callback has to contain indices 0 and 1
错误位置
FILE: /usr/share/nginx/html/Application/Home/Controller/IndexController.class.php  LINE: 26
ThinkPHP3.2.3 { Fast & Simple OOP PHP Framework } – [ WE CAN DO IT JUST THINK ]

原因: 在controller层获取传值用 $_GET['vote_id']; 而不是 $_GET('vote_id');


controller跳转model的方法

1.数据库中表名为 固定字符+表名
2.controller中写法
$term = D('表名')->terms($vote_id);
3.model中写法

<?php
namespace Home\Model;
use Think\Model;
class 表名Model extends Model{
    public function terms($vote_id){
        $condition['term_id'] = $vote_id;
        $term = D('表名')-> where($condition)->select();
        return $term;
    }
}

项目绑定到nginx 后启动报错

_STORAGE_WRITE_ERROR_:./Apps/Runtime/Cache/Home/ef328ad102d370c29a6a20add6f7ec71.php

原因
权限问题 ,要保证目录的所有者和nginx、php-fpm所使用的用户账号是一致的,
解决
我的nginx 和 php-fpm 权限为 www-data:www-data 所以

sudo chown www-data:www-data 项目名称 -R                     

contoller 层找view层.html 报错

模板不存在:./Application/Home/View/./Application/Home/View/Index/second.html.html

原因 匹配问题,
若controller层名字和view层中文件夹名字一致时

$this -> display(T('index'));

$this->display('index');

其中 index 为 view层 index.html 文件

若 controller 层 名字 和 view 层中 文件夹名字不相同

$this -> display('Test:second');

$this -> display('Test/second');

$this -> display(T('Test:second'));

$this -> display(T('Test/second'));
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值