I'm trying to write a result of a query
to a json_encode
and soon after writing to a field in my BD
, but I'm getting an error message and could not solve the problem.
What I'm doing:
$IdUsuario = $rowData['IdUsuario'];
// RECUPERANDO DADOS
$queryResult = array();
$this->GetConnection()->ExecQueryToArray('SELECT * FROM cadUsuario WHERE cadUsuario.IdUsuario = ' . $IdUsuario, $queryResult);
$string = json_encode($queryResult);
// INSERINDO DADOS DO ITEM LOG
$IdUsuario = $this->GetEnvVar('CURRENT_USER_ID');
// INSERINDO DADOS DA TABELA DE LogItens
$this->GetConnection()->ExecSQL('INSERT INTO cadLogItem (IdLog, Operacao, DataHoraOcorrencia, IdUsuario, Instancia) VALUES ('.$IdLog.', "AT", CURRENT_TIMESTAMP, '.$IdUsuario.', '.$string.' )');
And the error message is this:
Cannot execute SQL statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[{"0":"26","IdUsuario":"26","1":"[email protected]","Email":"carolmerigue' at line 1
The field in the DB is in the format MediumText
.