Invalid datetime format
recentactivity datetime NOT NULL
if I do
$this->info = account\models\user\Info::find_by_email($this->data['USRIE']) ActiveRecord\DateTime::$DEFAULT_FORMAT = 'db'; $this->info->recentactivity->setTimestamp(time()); $this->info->save();
or
$this->info->recentactivity->setTimestamp(time()); $this->info->save();
or
$this->info->recentactivity = date('Y-m-d H:i:s');
$this->info->save();
or
$this->info->recentactivity->setDate(date('Y'), date('m'), date('d'));
$this->info->save();
or
$this->info->recentactivity->setDate(date('Y'), date('m'), date('d'));
$this->info->recentactivity->setTime(date('H'), date('i'), date('s'));
$this->info->save();
as a result
'SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2014-06-08 04:12:19 GST'
whence GST?
Decision:
MysqlAdapter.php
class MysqlAdapter extends Connection
{
static $datetime_format = 'Y-m-d H:i:s'; // add this
I thought this problem looked familiar when I first saw it and the solution is definitely familiar.
I recently added the following lines in my initialising code (as opposed to editing the classes directly)
//ensure that the timestamps support MySQL by removing the timezone
//may not be necessary in future versions, required here for IIS compatibility
\ActiveRecord\Connection::$datetime_format = 'Y-m-d H:i:s';
as I understand this string in the class should be to avoid such situations. на сколько я понимаю то такая строка в классе должна быть, чтобы исключить такие ситуации.
Indeed it probably should be but I didn't want to overwrite the change when I uploaded a new version should the code necessary not be there and I didn't have the time to see if there was already a pull request for this.
I said it is rather for developers AR ... :)
я говорил это скорей для разработчиков AR ... :)
date and time format for the most part of MySQL standard and it makes sense to introduce a line on an ongoing basis, or something like that to avoid such situations.
формат даты и времени для MySQL по большей часть стандартный и имеет смысл ввести такую строку на постоянной основе, или что то подобное для избегания таких ситуаций.
This was almost addressed in #317 before I vanished but never got merged. Unless @andyleap wants to have a go, I'll block some time next week to refactor his PR and resubmit.
Sorry, unless @andyleap wants to take a swing at cleaning up #317, I meant.
I just updated my datetime branch so it's now based on current master, Travis build checks out: https://travis-ci.org/andyleap/php-activerecord
I haven't looked at it in a while, as I'm not using phpActiveRecord right now, but if there's anything I need to redo in there, I may have some time over the weekend to work on it.
This is still a problem today. I cannot (and should not) overwrite static class properties. How to fix this without creating modifying classes? Isn't there any config method available to set the format for datetimes?
Honestly, don't expect anything from me either. The authors on this project have shown repeated that they don't care about this problem, and I haven't touched PHP code in nearly a year now.
Oh damn, this thing is breaking a large project of mine and I have to get it back up as soon as possible. Is there any work around for it?
Invalid datetime format: 1292 Incorrect datetime value: '-0001-12-01 21:29:43'
With the following setting in the Connection class:
static $datetime_format = 'Y-m-d H:i:s';
thats a very weird datetime value to have, is the input into that query correct? it must be year month day.
this might be helpful: http://stackoverflow.com/questions/22218795/incorrect-datetime-value-1-1-0001-120000-am-for-column-call-time-at-row-1