protected $partition = array(
'field' => 'coinid',// 要分表的字段 通常数据会根据某个字段的值按照规则进行分表
'type' => 'id',// 分表的规则 包括id year mod md5 函数 和首字母
'expr' => '1',// 分表辅助表达式 可选 配合不同的分表规则
'num' => '4',// 分表的数目 可选 实际分表的数量
);
public function getDao($data=array()) {
if($data['coinid']>0) $data['coinid'] = $data['coinid'] - 1;
$table = $this->getPartitionTableName($data);
return $this->table($table);
}
控制器中的查询语句:
$Balance = D('Balance');
$aaa = $Balance->getDao($whereOrder)->select();
出错情况:
["Balance"] => string(154) "SELECT * FROM ( SELECT * FROM sz_balance_1 UNION SELECT * FROM sz_balance_2 UNION SELECT * FROM sz_balance_3 UNION SELECT * FROM sz_balance_4) AS Balance "
["_think_"] => string(19) "SHOW COLUMNS FROM ("
}
["lastInsID":protected] => NULL
["numRows":protected] => int(6)
["numCols":protected] => int(0)
["transTimes":protected] => int(0)
["error":protected] => string(189) "1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(' at line 1
最佳答案