Skip to content

Commit

Permalink
修复模型注解设置 poolName 不生效问题 #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Feb 5, 2020
1 parent 6e6d43c commit d1263fb
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Model/Model.php
Expand Up @@ -39,15 +39,8 @@ public function __init($data = [])
*/
public static function query($object = null, $poolName = null, $queryType = null)
{
if($object)
{
$class = BeanFactory::getObjectClass($object);
}
else
{
$class = static::__getRealClassName();
}
return BeanFactory::newInstance(ModelQuery::class, null, $class, $poolName, $queryType);
$meta = static::__getMeta($object);
return BeanFactory::newInstance(ModelQuery::class, null, $meta->getClassName(), $poolName ?? $meta->getDbPoolName(), $queryType);
}

/**
Expand All @@ -59,7 +52,8 @@ public static function query($object = null, $poolName = null, $queryType = null
*/
public static function dbQuery($object = null, $poolName = null, $queryType = null)
{
return Db::query($poolName, null, $queryType)->from(static::__getMeta($object)->getTableName());
$meta = static::__getMeta($object);
return Db::query($poolName ?? $meta->getDbPoolName(), null, $queryType)->from($meta->getTableName());
}

/**
Expand Down

0 comments on commit d1263fb

Please sign in to comment.