Subject Re: [firebird-php] timestamp milliseconds
Author Lester Caine
On 05/10/17 19:05, 'Daniel Miller' dmiller@... [firebird-php] wrote:
> well...something like:
>
> using arcane incantations of ibase_query...perform something similar to
> "select SOMETIME from SOMETABLE rows 1;" and store in $phpvar.
>
> So $phpvar now has a timestamp - but lacking the milliseconds.
>
> Now, go looking for that:
> "select VALUE, ABLE, INFO from SOMEOTHERTABLE where SOMETIME = $phpvar"
>
> This will return a null set. So my functional but highly offensive
> workaround is:
> "select VALUE, ABLE, INFO from SOMEOTHERTABLE where
> (SOMETIME - cast($phpvar as timestamp)) > 0
> and (SOMETIME - cast($phpvar as timestamp)) < .001
> and datediff(second from (SOMETIME - cast($phpvar as timestamp)) = 0"
>
> There has got to be a better way to do this.

What value are you putting in 'SOMETIME'?
https://firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-datatypes-datetime.html
flags just which presets return milliseconds and which do not, but part
of the problem with your example is that '$phpvar' is not the best value
to use as a key into other data. A generator value will prevent problems
with time stamps that clash ... which is something I have been hit by in
the past ;)

If you must use the raw timestamp as a key, then I'm still a little
confused since while I'm using second accurate data, it still displays
the '.000' in every timestamp string. What are you using to access
Firebird php_interbase or pdo_firebird? I only use the Interbase driver
not the PDO one, so I'm not sure if the PDO::FB_ATTR_TIMESTAMP_FORMAT
trims the milliseconds on the PDO one ...

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk