mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
Merge pull request #1 from oldrind/model_view
修正视图模型中所引用的表找不到模型的问题,字段带有()时别名丢失的问题
This commit is contained in:
@@ -38,7 +38,7 @@ trait View
|
|||||||
// 2011/10/17 添加实际表名定义支持 可以实现同一个表的视图
|
// 2011/10/17 添加实际表名定义支持 可以实现同一个表的视图
|
||||||
$tableName .= $view['_table'];
|
$tableName .= $view['_table'];
|
||||||
} else {
|
} else {
|
||||||
$tableName .= \think\Loader::model($name)->getTableName();
|
$tableName .= \think\Loader::table($name)->getTableName();
|
||||||
}
|
}
|
||||||
// 表别名定义
|
// 表别名定义
|
||||||
$tableName .= !empty($view['_as']) ? ' ' . $view['_as'] : ' ' . $name;
|
$tableName .= !empty($view['_as']) ? ' ' . $view['_as'] : ' ' . $name;
|
||||||
@@ -111,7 +111,7 @@ trait View
|
|||||||
{
|
{
|
||||||
if (false !== $pos = array_search('*', $fields)) {
|
if (false !== $pos = array_search('*', $fields)) {
|
||||||
// 定义所有字段
|
// 定义所有字段
|
||||||
$fields = array_merge($fields, \think\Loader::model($name)->getFields());
|
$fields = array_merge($fields, \think\Loader::table($name)->getFields());
|
||||||
unset($fields[$pos]);
|
unset($fields[$pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,6 @@ trait View
|
|||||||
*/
|
*/
|
||||||
protected function checkFields($fields = '*', $viewFields)
|
protected function checkFields($fields = '*', $viewFields)
|
||||||
{
|
{
|
||||||
var_dump($fields);
|
|
||||||
if (is_string($fields)) {
|
if (is_string($fields)) {
|
||||||
if ('*' == $fields) {
|
if ('*' == $fields) {
|
||||||
return $viewFields;
|
return $viewFields;
|
||||||
@@ -246,9 +245,9 @@ trait View
|
|||||||
}
|
}
|
||||||
} elseif (false !== $k = array_search($field, $viewFields, true)) {
|
} elseif (false !== $k = array_search($field, $viewFields, true)) {
|
||||||
// 存在视图字段
|
// 存在视图字段
|
||||||
$field = $k . $alias;
|
$field = $k;
|
||||||
}
|
}
|
||||||
$_fields[] = $field;
|
$_fields[] = $field . $alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_fields;
|
return $_fields;
|
||||||
|
|||||||
Reference in New Issue
Block a user