Currency Api Doesn't work with PostgreSQL
| Project: | Currency Exchange |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
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.
