I need to work on a legacy product with Laravel 4 (and I cannot update it).
I need to read the real query executed but I cannot get it.
This is my model:
class MigrationData {
protected $log = "";
public function executeMigration($id, $own, $company_id = null)
{
DB::transaction(function($conn) use($id, $own, $company_id) {
DB::connection('connection_01')->transaction(function($conn) use($id, $own, $company_id) {
// stuffes
$customer = new Customer();
try {
$customer->save();
Log::debug(DB::connection('connection_01')->getQueryLog());
} catch (Exception $e) {
Log::debug(DB::connection('connection_01')->getQueryLog());
}
exit();
})->enableQueryLog();
})
}
I can log other queries, but not the insert (the INSERT itself returns an error of Oracle Database but I would track exact query).
Thank you
The transaction method doesn't return an instance of its class. Let me give an example:
Therefore, you cannot make method chaining. Try to separate it like below: