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'));