Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function getAllProfiles ($db){
- $sql = "SELECT user_ID, name FROM profile";
- return $db -> query($sql);
- }
- function getProfile($db, $id){
- $sql = "SELECT * FROM profile WHERE user_ID = '$id'";
- $result = $db -> query($sql);
- return $result ->fetchObject();
- }
- function insertProfile($db, $name, $email, $enc_pw, $filename){
- $sql= "INSERT INTO 'profile' ('user_ID', 'name', 'email', 'pw', 'image','date' )
- VALUES (NULL, '$name' '$email', '$enc_pw', '$filename', CURDATE());";
- $db->query($sql);
- }
- function getAllPosts ($db, $id) {
- $sql= "SELECT post.*, profile.name FROM post, profile
- WHERE post.user_ID = profile.user_ID ORDER BY time desc";
- return $db ->query($sql);
- }
- function insertStatus ($db, $user_ID, $status, $filename) {
- $sql = "INSERT INTO `post` (`post_ID`, `user_ID`, `status`, `image`, `time`)
- VALUES (NULL, '$user_ID', '$status', '$filename', CURRENT_TIME())";
- $db ->query($sql);
- }
- function getComments ($db, $post_ID){
- $sql = "SELECT comment.*, profile.name FROM comment, profile
- WHERE comment.post_ID = $post_ID
- AND comment.user_ID = profile.user_ID";
- return $db->query($sql);
- }
- function insertComments ($db, $user_ID, $post_ID, $comment_text) {
- $sql = "INSERT INTO `comment` (`comment_ID`, `post_ID`, `user_ID`, `comment_text`, `date`)
- VALUES (NULL, '$post_ID', '$user_ID', '$comment_text', CURRENT_DATE())";
- $db ->query($sql);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement