Download & Extend

Currency Api Doesn't work with PostgreSQL

Project:Currency Exchange
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Charles Oertel
Status:closed (fixed)

Issue Summary

Hi my friends. I have troubles with this module all the time. It seems that there is no UNIX_TIMESTAMP( ) function in postgresql. This module is using such sql function to receive cached version of exchange rates from database.

* warning: pg_query() [function.pg-query]: Query failed: BŁĄD: funkcja unix_timestamp() nie istnieje LINE 1: ...m = 'USD' AND currency_to = 'PLN' AND timestamp > UNIX_TIMES... ^ HINT: Brak funkcji pasującej do podanej nazwy i typów argumentów. Być może należy dodać jawne rzutowanie typów. in E:\dev\web\webroot\includes\database.pgsql.inc on line 139.
* user warning: query: SELECT * FROM drupal_currencyapi WHERE currency_from = 'USD' AND currency_to = 'PLN' AND timestamp > UNIX_TIMESTAMP( ) - 3600 in E:\dev\web\webroot\sites\all\modules\currency\currency_api\currency_api.module on line 614.

Another thing. This module put exchange rates to database with this code:

function currency_api_save($currency_from, $currency_to, $rate) {
// delete outdated record, if exists
db_query("DELETE FROM {currencyapi} WHERE currency_from = '%s' AND currency_to = '%s'", $currency_from, $currency_to);
return db_query("INSERT INTO {currencyapi} VALUES ('%s', '%s', %f, %d)", $currency_from, $currency_to, $rate, time());
}

The module is using time() function from PHP when putting data to database. I think the same function should be used in query that generate the warning message above instead of database dependent sql function.

What do You think about?

--
Have a nice day.

Comments

#1

Version:6.x-1.0» 6.x-1.1
Assigned to:Anonymous» Charles Oertel
Status:active» needs review

I have made a patch for this. It involves removing the mysql-specific UNIX_TIMESTAMP function and using the PHP time() function instead. The change affects only one line in the currency_api.module so you can easily apply it by hand if you are unsure about patching.

AttachmentSize
currency_api_reroll.patch 973 bytes

#2

Version:6.x-1.1» 6.x-1.x-dev
Status:needs review» fixed

Thank you for the patch.

It is in the dev version that will be available in about 12 hours.

#3

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.