if ($sort){
$order = ‘totle_hours asc’;
}else{
$order = ‘totle_hours desc’;
}
d
a
t
a
[
′
d
a
t
a
′
]
=
(
n
e
w
S
t
u
d
e
n
t
P
u
n
c
h
C
a
r
d
(
)
)
−
>
a
l
i
a
s
(
′
s
′
)
−
>
l
e
f
t
J
o
i
n
(
′
h
i
s
i
c
h
i
l
d
r
e
n
c
′
,
′
c
.
i
d
=
s
.
c
i
d
′
)
−
>
l
e
f
t
J
o
i
n
(
′
h
i
s
i
u
s
e
r
u
′
,
′
u
.
i
d
=
c
.
u
i
d
′
)
−
>
l
e
f
t
J
o
i
n
(
′
h
i
s
i
d
e
m
e
n
t
g
r
o
u
p
d
′
,
′
d
.
i
d
=
c
.
s
c
h
o
o
l
i
d
′
)
−
>
l
e
f
t
J
o
i
n
(
′
h
i
s
i
s
c
h
o
o
l
m
o
n
e
y
m
′
,
′
m
.
i
d
=
c
.
c
l
a
s
s
i
d
′
)
−
>
w
h
e
r
e
(
data['data'] = (new StudentPunchCard())->alias('s') ->leftJoin('hisi_children c','c.id = s.cid') ->leftJoin('hisi_user u','u.id = c.uid') ->leftJoin('hisi_dementgroup d','d.id = c.schoolid') ->leftJoin('hisi_schoolmoney m','m.id = c.class_id') ->where(
data[′data′]=(newStudentPunchCard())−>alias(′s′)−>leftJoin(′hisichildrenc′,′c.id=s.cid′)−>leftJoin(′hisiuseru′,′u.id=c.uid′)−>leftJoin(′hisidementgroupd′,′d.id=c.schoolid′)−>leftJoin(′hisischoolmoneym′,′m.id=c.classid′)−>where(where)
->page(
p
a
g
e
,
page,
page,limit)
->group(‘s.cid’)
->field(‘c.name,c.id,c.thumb_tmp,c.class_hour,c.private_class,d.title as schoolname,u.real_name,m.title as cardname,
CAST(sum(s.class_hour) AS UNSIGNED) as totle_hours,u.username’)
->order($order)
->select();
借鉴:(异常请联系删除)
https://jingyan.baidu.com/article/90808022fab5dbfd91c80f35.html