예제 #1
0
     * @param currency string Currency short handle, defaults to config option
     * @return bool true or false
     **/
    public function update($userID, $address, $currency = NULL)
    {
        if ($currency === NULL) {
            $currency = $this->config['currency'];
        }
        if ($address != $this->getCoinAddress($userID) && $this->existsCoinAddress($address)) {
            $this->setErrorMessage('Unable to update coin address, address already exists');
            return false;
        }
        if ($this->getCoinAddress($userID) != NULL) {
            $stmt = $this->mysqli->prepare("UPDATE " . $this->getTableName() . " SET coin_address = ? WHERE account_id = ? AND currency = ?");
            if ($this->checkStmt($stmt) && $stmt->bind_param('sis', $address, $userID, $currency) && $stmt->execute()) {
                return true;
            }
        } else {
            $stmt = $this->mysqli->prepare("INSERT INTO " . $this->getTableName() . " (coin_address, account_id, currency) VALUES (?, ?, ?)");
            if ($this->checkStmt($stmt) && $stmt->bind_param('sis', $address, $userID, $currency) && $stmt->execute()) {
                return true;
            }
        }
        return $this->sqlError();
    }
}
$coin_address = new CoinAddress();
$coin_address->setDebug($debug);
$coin_address->setConfig($config);
$coin_address->setMysql($mysqli);
$coin_address->setErrorCodes($aErrorCodes);