PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Authentication » LiveUser » Bug #2215

Date format should be choosable to solve database dependency issues

Details

Submitted2004-08-25 16:47 UTC
Frommscifo at php dot net
StatusBogus
PackageLiveUser
PHP VersionIrrelevant
OSANY
Roadmaps(Not assigned)

Comments

[2004-08-25 16:47 UTC] mscifo at php dot net

Description:
------------
I can only find one instance where date() is used....in _updateUserData() in Auth/Container/DB.php.

The date format is hardcoded as 'Y-m-d H:i:s'. I think it would be a good idea to create a new option called 'dateFormat' in the options array that allows the user to specify the date format for the database being used. Also, by putting it in the authContainers array, this ensures that multiple auth containers with different database servers can be used without worrying about the date format breaking.

<snip>
'authContainers' => array(
'name' => array(
'type' => 'DB',
'dateFormat' => 'Y-m-d H:i:s',
<snip>

Then replace instances of hardcoded date formats with the set value.

[2004-08-28 15:52 UTC] smith at backendmedia dot com

Thank you for taking the time to write to us, but this is not
a bug.

if you want portability we recommend using the MDB or MDB2 container. We have decided to not work around the limitations of DB in LiveUser to improve portability. I am sorry for the inconvinience.

[2004-08-30 18:49 UTC] mscifo at php dot net

Lukas, even though this might not be a 'bug', it is still a problem for some databases. This problem can not be solved by switching to a MDB or MDB2 container.

When calling _updateUserData() in Auth/Container/MDB[2].php, the query uses MDB[2]_Date::unix2Mdbstamp($this->currentLogin). All unix2Mdbstamp() does is take the currentLogin (which is in epoch format) and converts it into this format 'Y-m-d H:i:s'

No matter which container you use, they all hardcode the date format to be used in the query, which is what is causing the problem since not all databases support that format by default.

[2004-08-30 19:14 UTC] smith at backendmedia dot com

Your observation is only partially correct. The MDB datatype conversion works as follows: you pass a date string with the 'Y-m-d H:i:s' format to either getValue('timestamp', $date) or quote($date, 'timestamp') which then converts the date into a native format. When you then fetch that date again you pass 'timestamp' again for the given column and the date is converted back to the 'Y-m-d H:i:s' format from the nativ format. So unless we forgot the pass the correct datatype somewhere it should work on MDB[2] just fine.

[2004-08-30 21:02 UTC] mscifo at php dot net

You're right Lukas. I wasn't tracing back all the way. It works as expected.