亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Thinkphp5 classes under the same page cannot be instantiated?
迷茫
迷茫 2017-05-24 11:30:42
0
1
554

When using thinkphp5, on the same page

namespace app\index\model;
    use think\Model;
    // 此處$target='admins';$behaviour='nihao';
    class Firstrow{
        public function mainChoose($target,$behaviour){
            $tableName = $target.'model';
            $openGate = new $tableName();
            return $result = $openGate -> $behaviour();
        }
    }

    class adminsmodel extends Model{
        protected $table = 'admins';
        public function nihao(){
            $result = $this->select()->collection()->toArray();
            return $result;
        }
    }

But the system keeps prompting that the adminsmodel class cannot be found
I suspected that it was a namespace problem, but there was no solution for a while. Could you please answer my questions

迷茫
迷茫

業(yè)精于勤,荒于嬉;行成于思,毀于隨。

reply all(1)
PHPzhong
正常來說你在另外寫個(gè)model
然后引用就行
use app/index/mode/adminsmodel;
new adminsmodel;

如果你非要這么任性
使用絕對路徑 
new app\index\model\adminsmodel 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template