Howdy,
I’m trying to simply set the value of a MySQL `datetime` field to the current time.
It seems like this should be the way to do it:
$req = $xpdo->newObject('quoterequest');
...
$req->set('query1_datetime', "NOW()");
But the field never makes it into the bindings array on it’s way to the final sql statement.
I tried phptype as "datetime" and "string" and the same result for both.
I have found that taking out the php "continue" statement from xpdoobject.class.php, line 1039, solves the problem for me.
But I wanted to pass this by the forum first, because it might be a php 4 issue, or maybe I didn’t find the magic combination of parameters in my schema...
...
elseif (in_array($this->_fieldMeta[$_k]['phptype'], array ('timestamp', 'datetime')) && in_array($fieldValue, $this->_currentTimestamps)) {
if ($this->_new) {
$this->_fields[$_k]= $this->strftime('%Y-%m-%d %H:%M:%S');
//continue;
}
$fieldType= PDO_PARAM_NULL;
}
...
On another matter related to dates and php4, I had been having difficulty setting MySQL fields of type `date` to anything pre-Unix epoch in php4. I discovered that setting phptype to ’string’ and setting the value in the xpdo object to a string, formatted "yyyy/mm/dd", does the trick.