Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id | post | userId |
- ---------|---------------|----------|
- 1 | "hello" | 1 |
- 2 | "world" | 1 |
- 3 | "ouch" | 2 |
- 4 | "test" | 1 |
- id | postId | fileName | time |
- ---------|---------------|----------|----------|
- 1 | 1 |"hey.jpg" | 0 |
- 2 | 1 |"test.png"| 53252354 |
- 3 | 2 |"asd.png" | 0 |
- 4 | 4 |"asd2.png"| 0 |
- $qry = $db->prepare('SELECT post.id, post.post, post.userId, att.fileName, att.time
- FROM posts AS post LEFT JOIN attachments AS att ON att.postId = post.id');
- $qry->execute();
- $postsArray = $qry->fetchAll(PDO::FETCH_ASSOC);
- [{'id': 1,
- 'post': 'hello',
- 'userId': 1,
- 'attachments': [{'fileName': 'hey.jpg', 'time:' 0}, ... ]
- }, ... ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement