Home > Backend Development > PHP Tutorial > thinkphp自带的分表 老是找不到表名 大神帮忙看看

thinkphp自带的分表 老是找不到表名 大神帮忙看看

WBOY
Release: 2016-06-06 20:23:21
Original
1308 people have browsed it

<code>模型中

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 
</code>
Copy after login
Copy after login

回复内容:

<code>模型中

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 
</code>
Copy after login
Copy after login

命名空间不正确

<code>use Think\Model\AdvModel;</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template