Jaap abskdjsadkj Wed Nov 03 22:55:57 -0400 2010

Subject: can't fill created_at field in new php install

Hi guys,

First of all I think it's good conduct to introduce myself; I'm Jaap, a student from Holland. I'd like to take the opportunity to thank the developers of php-activerecord. I needed to learn php for a project that concluded my bachelor study. I had 4 weeks to learn php and deliver a proof of concept and activerecord allowed me to skip a lot of php specific database stuff by just typing working code. Now to the problem I'm currently experiencing:

I had a project working 100% under a xampp lite install on windows xp. This xampp distribution had php version 5.3.2 (I think that's relevant). I recently manually installed php 5.3.3, mysql 5.1.52 essentials, apache 2.2.17 and phpmyadmin 3.3.8 and after a bit of tinkering I got my project working again except for (I think) one part. Code that creates/alters records in tables that contain a field named "created_at" produces the following error:

Fatal error: Uncaught exception 'ActiveRecord\DatabaseException' with message '22007, 1292, Incorrect datetime value: '2010-11-04 02:32:02 CET' for column 'created_at' at row 1' in C:\server\www\joker.taf.nu\public_html\governance2\php-activerecord\lib\Connection.php:276 Stack trace: #0 C:\server\www\joker.taf.nu\public_html\governance2\php-activerecord\lib\Table.php(317): ActiveRecord\Connection->query('INSERT INTO `me...', Array) #1 C:\server\www\joker.taf.nu\public_html\governance2\php-activerecord\lib\Model.php(803): ActiveRecord\Table->insert(Array) #2 C:\server\www\joker.taf.nu\public_html\governance2\php-activerecord\lib\Model.php(758): ActiveRecord\Model->insert(true) #3 C:\server\www\joker.taf.nu\public_html\governance2\php-activerecord\lib\Model.php(739): ActiveRecord\Model->save(true) #4 C:\server\www\joker.taf.nu\public_html\governance2\filldb.php(125): ActiveRecord\Model::create(Array) #5 {main} thrown in C:\server\www\joker.taf.nu\public_html\governance2\php-activerecord\lib\Connection.php on line 276

I use activerecord 1.0 and both 0.9 and 1.0 work under my xampp distro. I think the problem here is the string " CET" added to the datetime that activerecord wants to put in my datetime field. I looked in the datetime fields in my working xampp project and they only contain a date and a time, the timezone is not added in the xampp project and I am guessing that mysql does not allow the CET part to be put in a datetime. If that guess is correct, considering my story above, I assume that there is something that differs in my manual install from my xampp install that causes activerecord to append the CET timezone bit to the datetime and cause an error. I have no idea what this could be so if anyone can shine a little light on the problem I would be very grateful. I am willing to try any reasonable suggestions to figure this out, although I am wary altering my project files since it seems to be the a configuration thing causing my problem.

Jacques Fuentes Sun Dec 12 12:28:04 -0500 2010

This most likely has something to do with configuration settings by XAMPP. Have you tried googling for configuration problems with XAMPP & DateTime?

matthias sweertvaegher Mon Jan 17 14:32:41 -0500 2011

Hi Jaap,

did you find a proper solution? It is not xampp related. I just manually installed php 5.3.5 and configured the timezone to get rid of the strtotime warning and have the same issue.
For now, I just removed the T param in Connection.php line 410 :
return $datetime->format('Y-m-d H:i:s');

could it be a pdo mysql driver issue? Or did the timezone not get appended in previous php versions when timezone was not specified..?