0
Good morning Guys, I have a problem that is the following, I have a framework developed in the company, in this framework has a method that prepares data to be saved correctly in the database, it always expects a string , but at some point from time to time it receives an array and generates a PHP Warning, how can I identify which file called this method in the context of my application? Because in my environment there are several projects that consume this framework and I can’t identify, there is no tracert to go through the logs. Follow 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 the mysql_real_escape_string( $value ) that does not receive a string, sometimes it receives an array.