SugarCRM/ERROR

Conversion of … from Y-m-d h:ia to Y-m-d failed

onesixx 2013. 10. 16. 14:16
반응형

Error convert: Conversion of [last_7_days] from Y-m-d h:ia to Y-m-d failed

Error convert: Conversion of 2011-07-20 from Y-m-d H:i:s to h:iA failed
 

config.php setting include:
'default_date_format' => 'd/m/Y',
'default_time_format' => 'h:iA',
Any other info required to help resolve the issue.


https://github.com/sugarcrm/sugarcrm_dev/issues/90

Hi. Recently I've upgrade Sugar CRM CE from 6.2.1 to 6.4.2, my instance of Sugar CRM is in MSSQL, and now when I open the change log of any module it doesn't appears the date of change. I've read inthe developers' blog that it has changed the way to pass fields to the query to get in a certain format.

In the log file I found the next error:
[ERROR] convert: Conversion of 2011-12-15 19:33:50.000 from Y-m-d H:i:s to d-m-Y H:i failed

So, in the code of file "module/Audit/Audit.php", I found the next line:

$query = "SELECT ".$focus->get_audit_table_name().".*, users.user_name FROM ".$focus->get_audit_table_name().", users WHERE ".$focus->get_audit_table_name().".created_by = users.id AND ".$focus->get_audit_table_name().".parent_id = '$focus->id'".$order;

Well to fix my problem, I've removed the call to all fields of the table and I've set the names of each field to the query, but specifying the format as the function "to_display_date_time" expected ('Y-m-d H:i:s') to the field date_created.

But the function "convert" in the file "include/database/MssqlManager.php" just have 3 formats available:

protected $date_formats = array(

'%Y-%m-%d' => 10,
'%Y-%m' => 7,
'%Y' => 4,
);

I added the format that I need.

protected $date_formats = array(
'%Y-%m-%d %H:%i:%s' => 19,
'%Y-%m-%d' => 10,
'%Y-%m' => 7,
'%Y' => 4,
);

Then the code is the next


$dateCreatedField = $db->convert($focus->get_audit_table_name().'.date_created', "date_format", array("%Y-%m-%d %H:%i:%s"));

$order= ' order by '.$focus->get_audit_table_name().'.date_created desc' ;//order by contacts_audit.date_created desc
$query = "SELECT 
".$dateCreatedField." as date_created ,
".$focus->get_audit_table_name().".id, 
".$focus->get_audit_table_name().".parent_id, 
".$focus->get_audit_table_name().".created_by, 
".$focus->get_audit_table_name().".field_name, 
".$focus->get_audit_table_name().".before_value_string, 
".$focus->get_audit_table_name().".after_value_string, 
".$focus->get_audit_table_name().".after_value_text, 
".$focus->get_audit_table_name().".after_value_text, 
users.user_name FROM ".$focus->get_audit_table_name().", users WHERE ".$focus->get_audit_table_name().".created_by = users.id AND ".$focus->get_audit_table_name().".parent_id = '$focus->id'".$order;

Is correct my solution? or Are there other way to solved?

반응형

'SugarCRM > ERROR' 카테고리의 다른 글

SyntaxError: syntax error <!DOCTYPE html PUBLIC  (0) 2014.04.20