Can the field be Filter for the results of the query in the TP3.2 database? GetXxxAttribute () similar to laravel

stateful fields are often saved in the database, which are represented by numbers:

0-> fail / reject
1-> success / pass

and so on, I want to convert 0 or 1 into Chinese characters in the obtained results, is there any good way to quickly complete this kind of operation?

Feb.26,2021

foreach($ret as &$value){
    if($value['status'] == 1){
        $value['status'] = '';
    }else{
        $value['status'] = '';
    }
}

A foreach can solve this problem


Tp3.2 has never met, I don't know. However, you can write:
SELECT IF (status=1,' succeeded', 'failed') as res FROM DB WHERE id=1;

SELECT CASE status WHEN 1 THEN 'success' ELSE 'failed' END as res FROM DB WHERE id=1;


I remember there has been no tp5.0 since then, so let's write it by hand

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9b699-2f288.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9b699-2f288.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?