public
function
judeg(
$id
)
{
$rs
= Db::name(
'finance_class'
) -> field(
'parent_code'
) -> where(
'id'
,
$id
) -> select();
$i
= 1;
foreach
(
$rs
as
$k
=>
$v
){
if
(
$v
[
'parent_code'
] <> 0){
$i
+=
$this
-> judeg(
$v
[
'parent_code'
]);
}
}
return
$i
;
}
public
function
cid(
$id
,
$pid
)
{
$w
[
'parent_code'
] =
$id
;
$rs
= Db::name(
'finance_class'
)
-> field(
'id,code,name,parent_code'
)
-> where(
$w
)
-> order(
'code asc'
)
-> select();
$str
=
''
;
foreach
(
$rs
as
$k
=>
$v
) {
$name
=
$v
[
'name'
];
$_id
=
$v
[
'id'
];
$cutOff
=
''
;
for
(
$i
= 0;
$i
<
$this
-> judeg(
$_id
);
$i
++){
$cutOff
.=
'-'
;
}
if
(
$_id
==
$pid
){
$str
.=
'<p>他的id='
.
$_id
.
'====他的级别'
.
$cutOff
.
$name
.
'</p>'
;
}
else
{
$str
.=
'<p>他的id='
.
$_id
.
'====他的级别'
.
$cutOff
.
$name
.
'</p>'
;
}
$str
.=
$this
->cid(
$_id
,
$pid
);
}
return
$str
;
37}
public
function
finance_c()
{
$w
[
'type'
] =
'资产类'
;
$w
[
'parent_code'
] = 0;
$rs
= Db::name(
'finance_class'
)
-> field(
'id,code,name,parent_code'
)
-> where(
$w
)
-> select();
$str
=
''
;
foreach
(
$rs
as
$k
=>
$v
){
$str
.=
'<p>一级name:'
.
$v
[
'name'
].
'</p>'
;
$str
.=
$this
-> cid(
$v
[
'id'
],0);
}
echo
$str
;
}