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'));
發佈了46 篇原創文章 · 獲贊 12 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章