mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进Model类的getData方法
This commit is contained in:
@@ -163,7 +163,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
*/
|
||||
public function getData($name = '')
|
||||
{
|
||||
return isset($this->data[$name]) ? $this->data[$name] : $this->data;
|
||||
return array_key_exists($name, $this->data) ? $this->data[$name] : $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -797,6 +797,26 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到当前的数据表
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getTable($name = '')
|
||||
{
|
||||
if ($name || empty($this->table)) {
|
||||
$name = $name ?: $this->name;
|
||||
$tableName = $this->connection->getConfig('prefix');
|
||||
if ($name) {
|
||||
$tableName .= Loader::parseName($name);
|
||||
}
|
||||
} else {
|
||||
$tableName = $this->table;
|
||||
}
|
||||
return $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定当前操作的数据表
|
||||
* @access public
|
||||
@@ -1038,26 +1058,6 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到当前的数据表
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getTable($name = '')
|
||||
{
|
||||
if ($name || empty($this->table)) {
|
||||
$name = $name ?: $this->name;
|
||||
$tableName = $this->connection->getConfig('prefix');
|
||||
if ($name) {
|
||||
$tableName .= Loader::parseName($name);
|
||||
}
|
||||
} else {
|
||||
$tableName = $this->table;
|
||||
}
|
||||
return $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据表信息
|
||||
* @access public
|
||||
|
||||
Reference in New Issue
Block a user