升级thinkphp到5.1.39

This commit is contained in:
cxdbz committed 2019-11-28 19:33:13 +08:00
1 parent c8839fa4f8
commit a58d04e7e2
37 files changed
+546 -192

No files matched your search

@@ -11,6 +11,7 @@
namespace think\model\relation;
use Closure;
use think\db\Query;
use think\Loader;
use think\Model;
@@ -48,7 +49,7 @@ class HasMany extends Relation
*/
public function getRelation($subRelation = '', $closure = null)
{
if ($closure) {
if ($closure instanceof Closure) {
$closure($this->query);
}
@@ -163,7 +164,7 @@ class HasMany extends Relation
return 0;
}
if ($closure) {
if ($closure instanceof Closure) {
$return = $closure($this->query);
if ($return && is_string($return)) {
$name = $return;
@@ -186,7 +187,7 @@ class HasMany extends Relation
*/
public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '')
{
if ($closure) {
if ($closure instanceof Closure) {
$return = $closure($this->query);
if ($return && is_string($return)) {
@@ -216,7 +217,7 @@ class HasMany extends Relation
$this->query->removeWhereField($this->foreignKey);
// 预载入关联查询 支持嵌套预载入
if ($closure) {
if ($closure instanceof Closure) {
$closure($this->query);
}
@@ -292,14 +293,18 @@ class HasMany extends Relation
*/
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
{
$table = $this->query->getTable();
$model = basename(str_replace('\\', '/', get_class($this->parent)));
$relation = basename(str_replace('\\', '/', $this->model));
$table = $this->query->getTable();
$model = basename(str_replace('\\', '/', get_class($this->parent)));
$relation = basename(str_replace('\\', '/', $this->model));
$softDelete = $this->query->getOptions('soft_delete');
return $this->parent->db()
->alias($model)
->field($model . '.*')
->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType)
->when($softDelete, function ($query) use ($softDelete, $relation) {
$query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null);
})
->group($relation . '.' . $this->foreignKey)
->having('count(' . $id . ')' . $operator . $count);
}
@@ -321,13 +326,17 @@ class HasMany extends Relation
$this->getQueryWhere($where, $relation);
}
$fields = $this->getRelationQueryFields($fields, $model);
$fields = $this->getRelationQueryFields($fields, $model);
$softDelete = $this->query->getOptions('soft_delete');
return $this->parent->db()
->alias($model)
->group($model . '.' . $this->localKey)
->field($fields)
->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey)
->when($softDelete, function ($query) use ($softDelete, $relation) {
$query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null);
})
->where($where);
}