viewing paste Unknown #13485 | PHP

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    public function depositCredits($targetAccountID, $credits, $donationAmount = null)
    {
        $sql = "SELECT COUNT(account_id) AS accountExists FROM {$this->loginDatabase}.login WHERE account_id = ?";
        $sth = $this->connection->getStatement($sql);
        
        if (!$sth->execute(array($targetAccountID)) || !$sth->fetch()->accountExists) {
            return false; // Account doesn't exist.
        }
        
        $creditsTable = Flux::config('FluxTables.CreditsTable');
        
        if (!$this->hasCreditsRecord($targetAccountID)) {
            $fields = 'account_id, key, index, value';
            $values = '?, ?, ?, ?';
            
            /*if (!is_null($donationAmount)) {
                $fields .= ', last_donation_date, last_donation_amount';
                $values .= ', NOW(), ?';
            }*/
            
            $sql  = "INSERT INTO {$this->charMapDatabase}.`acc_reg_num_db` ($fields) VALUES ($values)ON DUPLICATE KEY UPDATE `value`=`value`+?";
            $sth  = $this->connection->getStatement($sql);
            $vals = array($targetAccountID, '#CASHPOINTS', 0, $credits);
            
            /*if (!is_null($donationAmount)) {
                $vals[] = $donationAmount;
            }*/
            
            return $sth->execute($vals);
        }
        else {
            $vals = array();
            $sql  = "UPDATE {$this->charMapDatabase}.`acc_reg_num_db` SET value = value + ? ";
 
            /*if (!is_null($donationAmount)) {
                $sql .= ", last_donation_date = NOW(), last_donation_amount = ? ";
            }*/
            
            $vals[] = $credits;
            /*if (!is_null($donationAmount)) {
                $vals[] = $donationAmount;
            }*/
            $vals[] = $targetAccountID;
            
            $sql .= "WHERE account_id = ? and `key` = '#CASHPOINTS'";
            $sth  = $this->connection->getStatement($sql);
            
            return $sth->execute($vals);
        }
    }
Viewed 730 times, submitted by Guest.