PDO: How to fetch TIMESTAMP values?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I recently began evaluating the feasibility of reworking our current 
database access framework, which utilizes the PHP-native drivers for our 
database (Interbase), to one which makes use of the PDO extension. 
Unfortunately, I quickly hit a roadblock.

I have tried every permutation available in the PDO documentation, as far as 
I can see, in order to retrieve the value of a TIMESTAMP-type field from a 
given table, but so far I have been unsuccessful.

Using the PHP-native functions for Interbase, I used to be able to 
accomplish this with the following code:

<?php
  $sql = "SELECT TIMESTAMP_FIELD FROM MY_TABLE";
  $result = ibase_query($dbh, $sql);

  $row = ibase_fetch_row($result, IBASE_UNIXTIME);
  $field = $row[0];

  echo "$field";
?>

Here is one of the many [failed] methods I have attempted using a PDO:

<?php
  $sql = "SELECT TIMESTAMP_FIELD FROM MY_TABLE";
  $row = $dbh->query($sql);

  $field = $row['TIMESTAMP_FIELD'];

  echo "$field";
?>

In the first instance, a numeric (integer) value would be displayed on the 
screen.  In the PDO example, nothing is displayed.

I have also tried rewriting the PDO code above as a prepared statement, but 
i get the same result.

Has anyone else bumped up against problems with TIMESTAMP fields when using 
the Interbase PDO driver or some other?  Any suggestions would be 
appreciated.  Thanks! 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux