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
PHPz2017-05-24 11:32:42
正常来说你在另外写个model
然后引用就行
use app/index/mode/adminsmodel;
new adminsmodel;
如果你非要这么任性
使用绝对路径
new app\index\model\adminsmodel