ARTICLE AD BOX
My function to get input from the user using Leaf PHP with an SQLite database should create a POST method call to create a thread, and every message (including the first one) should be in a comments table related to the threads table:
app()->post('/createThread', function () { $user = auth()->user()->get(); if (!$user) { return response()->render('login',[ 'status' => 'error', 'message' => 'Debe iniciar sesión', 'data' => auth()->errors(), ]); } $userData = request()->get(['title', 'message', 'topic_id']); $db = db(); $db->insert('threads')->params([ 'title' => $userData['title'], 'user_id' => auth()->id(), 'topic_id' => $userData['topic_id'] ])->execute(); $thread_id = $db->lastInsertId(); $db->insert('comments')->params([ 'message'=>$userData['message'], 'user_id' => auth()->id(), 'thread_id'=>$thread_id ])->execute(); return response()->redirect('/thread/{$thread_id}'); });However, I'm getting error 5. With a transaction function callback I get another error:
no active transaction
