升级thinkphp到5.1.39
This commit is contained in:
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\Loader;
|
||||
use think\Model;
|
||||
|
||||
@@ -49,7 +50,7 @@ class BelongsTo extends OneToOne
|
||||
*/
|
||||
public function getRelation($subRelation = '', $closure = null)
|
||||
{
|
||||
if ($closure) {
|
||||
if ($closure instanceof Closure) {
|
||||
$closure($this->query);
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ class BelongsTo extends OneToOne
|
||||
*/
|
||||
public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '')
|
||||
{
|
||||
if ($closure) {
|
||||
if ($closure instanceof Closure) {
|
||||
$return = $closure($this->query);
|
||||
|
||||
if ($return && is_string($return)) {
|
||||
@@ -111,7 +112,7 @@ class BelongsTo extends OneToOne
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($closure) {
|
||||
if ($closure instanceof Closure) {
|
||||
$return = $closure($this->query);
|
||||
|
||||
if ($return && is_string($return)) {
|
||||
@@ -140,13 +141,17 @@ class BelongsTo extends OneToOne
|
||||
$relation = basename(str_replace('\\', '/', $this->model));
|
||||
$localKey = $this->localKey;
|
||||
$foreignKey = $this->foreignKey;
|
||||
$softDelete = $this->query->getOptions('soft_delete');
|
||||
|
||||
return $this->parent->db()
|
||||
->alias($model)
|
||||
->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey) {
|
||||
$query->table([$table => $relation])
|
||||
->field($relation . '.' . $localKey)
|
||||
->whereExp($model . '.' . $foreignKey, '=' . $relation . '.' . $localKey);
|
||||
->whereExp($model . '.' . $foreignKey, '=' . $relation . '.' . $localKey)
|
||||
->when($softDelete, function ($query) use ($softDelete, $relation) {
|
||||
$query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,12 +172,16 @@ class BelongsTo extends OneToOne
|
||||
$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)
|
||||
->field($fields)
|
||||
->join([$table => $relation], $model . '.' . $this->foreignKey . '=' . $relation . '.' . $this->localKey, $this->joinType)
|
||||
->when($softDelete, function ($query) use ($softDelete, $relation) {
|
||||
$query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null);
|
||||
})
|
||||
->where($where);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace think\model\relation;
|
||||
|
||||
use Closure;
|
||||
use think\Collection;
|
||||
use think\db\Query;
|
||||
use think\Exception;
|
||||
@@ -166,7 +167,7 @@ class BelongsToMany extends Relation
|
||||
*/
|
||||
public function getRelation($subRelation = '', $closure = null)
|
||||
{
|
||||
if ($closure) {
|
||||
if ($closure instanceof Closure) {
|
||||
$closure($this->query);
|
||||
}
|
||||
|
||||
@@ -377,7 +378,7 @@ class BelongsToMany extends Relation
|
||||
|
||||
$pk = $result->$pk;
|
||||
|
||||
if ($closure) {
|
||||
if ($closure instanceof Closure) {
|
||||
$return = $closure($this->query);
|
||||
|
||||
if ($return && is_string($return)) {
|
||||
@@ -401,7 +402,7 @@ class BelongsToMany 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)) {
|
||||
@@ -428,7 +429,7 @@ class BelongsToMany extends Relation
|
||||
protected function eagerlyManyToMany($where, $relation, $subRelation = '', $closure = null)
|
||||
{
|
||||
// 预载入关联查询 支持嵌套预载入
|
||||
if ($closure) {
|
||||
if ($closure instanceof Closure) {
|
||||
$closure($this->query);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loaded 3 of 37 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user