sqlite3 time incorrectly interpreted by php

Issue #386 resolved
Florin Muntean created an issue

query of a view with time function returns the following error:

Warning: time() expects exactly 0 parameters, 3 given in /var/www/html/phpliteadmin/index.php on line 4744

no rows are returned.

this is the view:

CREATE VIEW 'vLights' as SELECT l.ts,l.duration,l.device,date(l.ts,'unixepoch','localtime') as DATE,time(l.ts,'unixepoch','localtime') as TIME, p.avgW, cast(l. duration as real)/60/60*p.avgW as powerW FROM "LIGHT" l join power p on l.device=p.device

Comments (9)

  1. Florin Muntean reporter

    any update?

    if I run the query inside the sqlite3 command line it works as expected.

    this is the function I use in the query:
    date(l.ts,'unixepoch','localtime') as DATE,
    time(l.ts,'unixepoch','localtime') as TIME

  2. phpLiteAdmin repo owner

    Please have a look at your $custom_functions config variable. I just saw that the sample config contains 'time' in here. Remove this. With custom functions you can access PHP functions from SQL in phpliteadmin. In this case, this overwrites the SQL time function with the PHP time function.

  3. phpLiteAdmin repo owner

    Yes but the function is overwritten because of your configuration. You can remove 'time' from the $custom_functions config setting, then it won’t be overwritten anymore. I admit that the sample config is bad and should not include the time function. But you can easily solve your problem by adjusting the config. Probably the old config sample did not include this, which is why it worked before.

  4. Florin Muntean reporter

    thanks, That fixed my issue. however I still think this is a bug as that was default configuration and I would not expect the sqlite internal functions to be overridden by default.

  5. phpLiteAdmin repo owner

    Of course you are right that this is a bad default configuration. I just removed it from the default config. Thank you for reporting this.

  6. Log in to comment