改进关联模型的关联键值和表名读取

This commit is contained in:
thinkphp
2016-04-20 15:31:25 +08:00
parent b3d592da95
commit 02934b0d27
3 changed files with 8 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ namespace think\model;
use think\Db;
use think\Exception;
use think\Loader;
use think\model\Pivot;
class Relation
@@ -257,7 +258,7 @@ class Relation
*/
protected function match($model, $relation, &$result)
{
$modelName = strtolower(basename(str_replace('\\', '/', $model)));
$modelName = Loader::parseName(basename(str_replace('\\', '/', $model)));
// 重新组装模型数据
foreach ($result->toArray() as $key => $val) {
if (strpos($key, '__')) {