2012-06-22 34 views
1

我在Prestashop論壇上提出過這個問題,但至今還沒有答覆。Prestashop 1.4.3我需要獲取數據庫值並在MailAlerts模塊中使用它

我需要能夠在mailalert模塊中使用的新訂單電子郵件中添加一個sagepay代碼。

我有什麼;

// Filling-in vars for email 
$template = 'new_order'; 
$subject = $this->l('New order'); 
$spvtxc = Db::getInstance()->ExecuteS("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '$order->id_cart'"); 
... 
$templateVars = array(
'{firstname}' => $customer->firstname, 
'{lastname}' => $customer->lastname, 
... 
'{sagepay_no}' => $spvtxc, 
... 
); 

每次我測試一個事務時,$ spvtxc返回'ARRAY'。 我試過了;

$spvtxc = '5'; 

如預期的那樣,返回5作爲sagepay號碼,所以我相信變量被調用並添加到電子郵件。 我試過了;

$spvtxc = Db::getInstance()->ExecuteS("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '2'"); 

所以這應該設置$ spvtxc到是definatly那裏(我手動添加在數據庫)的值,但仍返回「數組」。

如果有人可以指出我錯過了什麼,它是非常appriceated。

回答

1

由於我只需要返回一個值,我應該使用getValue函數而不是ExecuteS。

$spvtxc = Db::getInstance()->getValue("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '$order->id_cart'"); 

返回值。

相關問題