模型中namespace Home\Model;use Think\Model;class FollowModel extends AdvModel{ //分表方式 protected $partition = array('field'=>'vid','type'=>'mod','num'=>'2'); //擷取動作表名 public function getDao($data=array()) {// $data = empty($data) ? $_POST : $data; $table = $this->getPartitionTableName($data); return $this->table($table); } }方法中namespace Home\Controller;use Think\Controller;class ActionController extends Controller { public function Test() { //擷取分表 $soft_tj_table = D("Follow")->getDao(array('vid'=>5)); dump($soft_tj_table); } }由於使用了進階模型 返回的表名老是報錯 $table
回複內容:
模型中namespace Home\Model;use Think\Model;class FollowModel extends AdvModel{ //分表方式 protected $partition = array('field'=>'vid','type'=>'mod','num'=>'2'); //擷取動作表名 public function getDao($data=array()) {// $data = empty($data) ? $_POST : $data; $table = $this->getPartitionTableName($data); return $this->table($table); } }方法中namespace Home\Controller;use Think\Controller;class ActionController extends Controller { public function Test() { //擷取分表 $soft_tj_table = D("Follow")->getDao(array('vid'=>5)); dump($soft_tj_table); } }由於使用了進階模型 返回的表名老是報錯 $table
命名空間不正確
use Think\Model\AdvModel;