Improvements to class\User

Details of modifications which users can incorporate within Enuuk Auction Platform free of charge
Post Reply
RWAP
Site Admin
Posts: 750
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Improvements to class\User

Post by RWAP » Fri Sep 02, 2011 12:08 am

I have re-written the function getListFromDB() in class\User.php to reduce the load on the server and SQL calls.

This has been passed to phpAuction for consideration in future releases.

The improved code is:

Code: Select all

    static public function getListFromDB(MyPDO $DB, $restrictions = '')
    {
        $sql = 'select id,name,countryId,prestige,email,active,seller,trustSeller,admin,registerDate,validEmail,address,city,state,zip,birthdate,phone,bidCredit,userLanguage  from '.self::DB_TABLE.' '.$restrictions  ;
        $rs = $DB->query($sql);
        $data= $rs->fetchAll(PDO::FETCH_ASSOC);
        unset($rs);
        $statusSql = 'select status as trustUserRequestStatus from '.self::DB_USER_TRUST_REQUEST_TABLE.' where userId=:id limit 1';
        $query = $DB->prepare($statusSql);
        foreach($data as $k=>$v){
            // Retrieving users custom fields data
            $dataCustom = self::getCustomUserData($DB,$v['id']);
            if($dataCustom){
                foreach($dataCustom as $key=>$value){
                    if(CustomField::isActive($DB,intval($value['userFieldId']))){
                         $tmp[$value['userFieldId']]= $value;
                    }
                }
				$v['custom'] = $tmp;
				unset($tmp);
            }
            $query->execute(array(':id'=>$v['id']));
            $dataStatus = $query->fetch(PDO::FETCH_ASSOC);
            if($dataStatus){
                foreach($dataStatus as $key=>$val){
                    $v[$key] = $val;
                }
            }else{
                $v['trustUserRequestStatus'] = '';
            }
            $data[$k] = $v;
        }
        unset($query);
        return $data;
    }
Does anyone have any other suggestions? :D

cynic-
Posts: 73
Joined: Tue Dec 28, 2010 4:00 pm
Contact:

Re: Improvements to class\User

Post by cynic- » Mon Sep 26, 2011 2:16 pm

I suggest phpAuction team to pay you for each line of code you write for their platform improvement :D

Great job
Enuuk auction platform v2.6 / upgrading to v2.8
French translation in progress

RWAP
Site Admin
Posts: 750
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Improvements to class\User

Post by RWAP » Mon Sep 26, 2011 2:20 pm

Oh if only :roll:

I am waiting to see if anyone else has some good suggestions like this one!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest