PHP无法显示SQL的结果

时间:2018-07-01 06:35:10

标签: php sql arrays arr

我对sql有问题。我正在尝试回显我的SQL结果,但未与我的代码一起显示。如何回显import base64 import secrets import hashlib from Crypto.Cipher import AES from Crypto import Random class AesCrypt256: BLOCK_SIZE = 256 def pkcs5_pad(self,s): return s + (self.BLOCK_SIZE - len(s) % self.BLOCK_SIZE) * chr(self.BLOCK_SIZE - len(s) % self.BLOCK_SIZE) def pkcs5_unpad(self,s): return s[0:-s[-1]] def encrypt(self, key, value): iv = Random.new().read(16) key = hashlib.sha256(key).digest()[:self.BLOCK_SIZE] cipher = AES.new(key, AES.MODE_CBC, iv) print(len(key)) print(len(self.pkcs5_pad(value))) crypted = cipher.encrypt(self.pkcs5_pad(value)) return iv+crypted def decrypt(self, key, value): key = hashlib.sha256(key).digest()[:self.BLOCK_SIZE] iv = value[:16] crypted = value[16:] cipher = AES.new(key,AES.MODE_CBC,iv) return self.pkcs5_unpad(cipher.decrypt(crypted)) def encryptB64(self, key, value): return base64.b64encode(self.encrypt(key.encode(), value)).decode() def decryptB64(self, key, value): return self.decrypt(key.encode(),base64.b64decode(value)).decode() def randomstring(size=64): return secrets.token_urlsafe(size) crypter = AesCrypt256() crypter.encryptB64('hallo123', randomstring(size=1024)) 并转换成35000这样的千千?谢谢

35K

我正在尝试使用此代码。

$billings_sum = $wpdb->get_results( "SELECT SUM(bl_currency) from billings WHERE bl_user = '$user_id'" );

var_dump($billings_sum[0]);

Var_dump结果:

echo $billings_sum[0]["SUM(bl_currency)"];

2 个答案:

答案 0 :(得分:1)

看来您得到的输出是“对象”形式的。要访问对象值,您需要像这样-

$billings_sum = (object) array(
    'SUM(bl_currency)' => 35000
);

echo $billings_sum->{'SUM(bl_currency)'};

希望有帮助。

问候,Shahriar:)

答案 1 :(得分:0)

您可以使用{}之类的花括号,遵循以下代码

echo $billings_sum[0]->{'SUM(bl_currency)'};

希望它会起作用。