Hello everyone, I have a problem that is as follows, I have a framework developed in the company, this framework has a method that prepares data to be saved correctly in the database, it always expects a string, but at some point I do not know how to do this, but I do not know how to do this, but I do not know how to do this. to scroll through the logs. Here is the framework method that appears in the log:
insira o código aqui/**
* Prepara o valor para ser salvo no banco de dados.
* Em 2013-06-07 17:07:33 alterei o nome deste método de _to_mysql para normalize_to_mysql
* e deixe ele público para permitir alterarmos o comportamento local ou em futuras versões.
*
* @param string $field Nome do campo.
* @param mixed $value Valor do campo.
*
* @return string $value
*/
public function normalize_to_mysql( $field , $value ) {
// Se for false ou null retornar null direto
if ( is_null( $value ) || $value === false || $value === "" ) {
return "NULL" ;
}
$properties = $this->_config{"fields"}{$field} ;
// Tratamento especial para campos de data (date e datetime)
if ( ( $properties{"type"} == "date" || $properties{"type"} == "datetime" || $properties{"type"} == "time" ) && ! empty( $value ) ) {
if ( spiffy_types::is_object_date( $value ) ) {
$object_date = $value ;
}
else {
$object_date = DateTime::createFromFormat( $properties{"input_format"} , $value ) ;
$date_errors = DateTime::getLastErrors() ;
}
if ( spiffy_types::is_object_date( $object_date ) && empty( $date_errors{"warning_count"} ) && empty( $date_errors{"error_count"} ) ) {
if ( $properties{"type"} == "date" ) {
$value = $object_date->format( "Y-m-d" ) ;
}
else if ( $properties{"type"} == "time" ) {
$value = $object_date->format( "H:i:s" ) ;
}
else {
$value = $object_date->format( "Y-m-d H:i:s" ) ;
}
}
else {
$value = "NULL" ;
}
}
return sprintf( "'%s'" , mysql_real_escape_string( $value ) ) ;
}
The error occurs in mysql_real_escape_string ($ value) that does not receive a string, sometimes receives an array.