Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing empty array on notes #4

Open
LifeRecall opened this issue Feb 24, 2023 · 1 comment
Open

Missing empty array on notes #4

LifeRecall opened this issue Feb 24, 2023 · 1 comment

Comments

@LifeRecall
Copy link

Had to add the empty array param for the query to work:

query('SELECT * FROM notes WHERE user_id = 1'_, []_)** ->fetchAll();
@fabyo0
Copy link

fabyo0 commented Feb 4, 2024

You can add session user id and take notes accordingly

Authenticator.php

public function login($user): void
    {
        Session::put('user',[
            'email' => $user['email'],
            'id' => $user['id'],
        ]);
        
        session_regenerate_id(true);
    }

notes/index.php

$userID = $_SESSION['user']['id'];

$notes = $db->query("SELECT * FROM notes WHERE user_id = {$userID}")->get();

view("notes/index.view.php", [
    'heading' => 'My Notes',
    'notes' => $notes
]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants