Jump to content
  • 0
3TAJIOH

Donate to CashPoints

Question

	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');
		$cashesTable = Flux::config('FluxTables.CashTable');
		
		if (!$this->hasCreditsRecord($targetAccountID)) {
			$fields = 'account_id, balance';
			$values = '?, ?';
			
			if (!is_null($donationAmount)) {
				$fields .= ', last_donation_date, last_donation_amount';
				$values .= ', NOW(), ?';
			}
			
			$sql  = "INSERT INTO {$this->loginDatabase}.$creditsTable ($fields) VALUES ($values)";
			$sth  = $this->connection->getStatement($sql);
			$vals = array($targetAccountID, $credits);
			
			if (!is_null($donationAmount)) {
				$vals[] = $donationAmount;
			}
			
			return $sth->execute($vals);
		}
		else {
			$vals = array();
			$sql  = "UPDATE {$this->loginDatabase}.$cashesTable SET value = value + ? ";

			
			$vals[] = $credits;
			if (!is_null($donationAmount)) {
				$vals[] = $donationAmount;
			}
			$vals[] = $targetAccountID;
			
			$sql .= "WHERE account_id = ?";
			$sth  = $this->connection->getStatement($sql);
			
			return $sth->execute($vals);
		}
	}

 

FluxCP cannot edit table acc_reg_num? Donation to cp_credits works normally.

Edited by 3TAJIOH
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
4 minutes ago, crazyarashi said:

So what should we exactly should we do with the function you provided again?

Updated. I want to make donation to CashPoints, not to Credit Points.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.