改进Query类

This commit is contained in:
thinkphp
2016-05-18 10:20:34 +08:00
parent c0048e80ea
commit 198ea76923
2 changed files with 15 additions and 3 deletions

View File

@@ -875,7 +875,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 设置当前数据表和模型名
if (!empty($class->table)) {
self::$links[$model]->table($class->table);
self::$links[$model]->setTable($class->table);
} else {
$name = !empty($class->name) ? $class->name : basename(str_replace('\\', '/', $model));
self::$links[$model]->name($name);

View File

@@ -786,14 +786,26 @@ class Query
}
/**
* 指定数据表
* 指定默认数据表
* @access public
* @param string $table 表名
* @return $this
*/
public function setTable($table)
{
$this->table = $table;
return $this;
}
/**
* 指定当前操作的数据表
* @access public
* @param string $table 表名
* @return $this
*/
public function table($table)
{
$this->table = $table;
$this->options['table'] = $table;
return $this;
}