1
I am trying to use the following command to insert:
$sql = "INSERT INTO tabela (campo1, campo2, campo2, campo4)
values(:campo1, :campo2, :campo3,'S')";
$campos = array(
':campo1' => $nome,
':campo2' => $endreco,
':campo3' => $bairro
);
$insert = DB::insert( $sql, $campos );
But is returning the following message:
Object of class stdClass could not be converted to string (SQL: INSERT INTO table (field 1, field 2, field 2) values(:field 1, :field 2, :field 3)
I don’t know I tried to change the insert
for select
and nothing
Can you help me?
[EDIT 1]
public function salvar( Request $request ){
$solicitante = $request->input( 'solicitante' );
$usuario = $request->input( 'usuario' );
$setor = $request->input( 'setor' );
$descricao = $request->input( 'descricao' );
$ramal = $request->input( 'ramal' );
$observacao = $request->input( 'observacao' );
$codigo = $this->proxRegistro();
$sql = "insert into abertura_chamado
(cd_os, dt_pedido, ds_servico, ds_observacao, nm_solicitante,TP_SITUACAO, CD_SETOR,
CD_MULTI_EMPRESA, CD_TIPO_OS, NM_USUARIO, DT_ULTIMA_ATUALIZACAO,
SN_SOL_EXTERNA, CD_OFICINA, SN_ORDEM_SERVICO_PRINCIPAL,
SN_PACIENTE, DT_ENTREGA, TP_PRIORIDADE, SN_RECEBIDA, SN_ETIQUETA_IMPRESSA,
SN_EMAIL_ENVIADO, TP_CLASSIFICACAO, CD_ESPEC, DS_RAMAL, TP_LOCAL
)
values
( ?, SYSDATE, ?, ?, ?, 'S', ?,
1, 30, ? , SYSDATE ,
'S', 14, 'S',
'N', SYSDATE , ?, 'N', 'N',
'N', 'P', 31, ?, 'I')";
$prioridade = 'E';
$campos = array(
$codigo,
$descricao,
$observacao,
$solicitante,
$setor,
$usuario,
$prioridade,
$ramal
);
DB::insert( $sql, $campos );
}
[EDIT2]
The error message continues
– adventistaam
@adventistaam put in your question your true code! what proposed to you is through the documentation has no way to err!
– novic
Ready added the real code
– adventistaam
@adventistaam paste the image of error in your question!
– novic
I’ve already added the image
– adventistaam
then the mistake is in Str where you use it? @adventistaam
– novic
Sorry I didn’t understand your question
– adventistaam
The problem is not in that code @adventistaam where you use
Str
???– novic
In fact the only str command I use is that sql command
– adventistaam