Closed douglasmsantos closed 11 months ago
I have never used this package to manipulate the DB data, only read from it, but generally a good idea when debugging is find the simpliest case when it breaks. You can try executing the statement manually. Something like:
app(\Illuminate\Database\DatabaseManager::class)
->connection('firebird_connection_name')
->getPdo()
->exec("INSERT INTO foo (bar) VALUES ('Lorem ipsum')");
I'm not sure about the SQL syntax though, I've never inserted anything to Firebird.
If it works ok, you can try following the path of Model::save()
to see where the query breaks or some other functionality behaves not like it should.
Thanks @KKSzymanowski,
Really if I do it the way you mentioned it inserts without problems.
Exactly as if done directly in PHP with the PDO without Laravel.
Unfortunately in this case I would lose all the practicality of Eloquent, but it solves for now the situation.
The strange thing is that it is only in the BLOB field that the problem happens. In the varchar field I solved, deleting and creating the field again by setting Varchar (2000) by default
Unfortunately in this case I would lose all the practicality of Eloquent, but it solves for now the situation.
I'm not suggesting to abandon Eloquent. Running raw queries is a good starting point to see where the problem lies.
The strange thing is that it is only in the BLOB field that the problem happens.
You can view Illuminate\Database\Query\Builder::insert()
to see what the
$this->grammar->compileInsert($this, $values)
call returns.
I think I'm doing it completely wrong.
But I tried to do it in two different ways.
if(! DB::connection('firebird')->insert("INSERT INTO rom1002(ID, FK_ROM1010, ST_NOME, DM_STATUS, TS_DESCRICAO) VALUES('".$valor."', '".$request->IdAssociado."', '".$request->Nome."', '".$request->Status."', '".$request->Descricao."')")){
return response()->json(["message" => "Erro ao cadastrar dependente.", "situacao" => "1"], 201);
}
dd(DB::connection('firebird')->getQueryLog());
The above code returns an empty array.
if(! app(\Illuminate\Database\DatabaseManager::class)
->connection('firebird')
->getPdo()
->exec(
"INSERT INTO rom1002(ID, FK_ROM1010, ST_NOME, DM_STATUS, TS_DESCRICAO) VALUES('".$valor."', '".$request->IdAssociado."', '".$request->Nome."', '".$request->Status."', '".$request->Descricao."')")
->$this->grammar->compileInsert($this, $values)){
return response()->json(["message" => "Erro ao cadastrar dependente.", "situacao" => "1"], 201);
}
dd($this->grammar->compileInsert($this, $values));
Already the above code returns the error Trying to get property of non-object
Hello, I'm having trouble inserting text inside a blob-type field. In some cases it inserts and others do not. In both cases when I use the save method does not return error, but also does not return success. I've done a test changing the field type to Varchar from 2000 and I have the same problem. I was wondering if anyone had this problem and how it worked.