Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <?php
  2.  
  3. function getAllProfiles ($db){
  4.     $sql = "SELECT user_ID, name FROM profile";
  5.     return $db -> query($sql);
  6. }
  7.  
  8. function getProfile($db, $id){
  9.     $sql = "SELECT * FROM profile WHERE user_ID = '$id'";
  10.     $result = $db -> query($sql);
  11.     return $result ->fetchObject();
  12. }
  13.  
  14. function insertProfile($db, $name, $email, $enc_pw, $filename){
  15.     $sql= "INSERT INTO 'profile' ('user_ID', 'name', 'email', 'pw', 'image','date' )
  16.             VALUES (NULL, '$name' '$email', '$enc_pw', '$filename', CURDATE());";
  17.     $db->query($sql);
  18. }
  19.  
  20. function getAllPosts ($db, $id) {
  21.     $sql= "SELECT post.*, profile.name FROM post, profile
  22.     WHERE post.user_ID = profile.user_ID ORDER BY time desc";
  23.     return $db ->query($sql);
  24. }
  25.  
  26. function insertStatus ($db, $user_ID, $status, $filename) {
  27.     $sql = "INSERT INTO `post` (`post_ID`, `user_ID`, `status`, `image`, `time`)
  28.             VALUES (NULL, '$user_ID', '$status', '$filename', CURRENT_TIME())";
  29.     $db ->query($sql);
  30. }
  31.  
  32. function getComments ($db, $post_ID){
  33.     $sql = "SELECT comment.*, profile.name FROM comment, profile
  34.             WHERE comment.post_ID = $post_ID
  35.             AND comment.user_ID = profile.user_ID";
  36.     return $db->query($sql);
  37. }
  38.  
  39. function insertComments ($db, $user_ID, $post_ID, $comment_text) {
  40.     $sql = "INSERT INTO `comment` (`comment_ID`, `post_ID`, `user_ID`, `comment_text`, `date`)
  41.             VALUES (NULL, '$post_ID', '$user_ID', '$comment_text', CURRENT_DATE())";
  42.     $db ->query($sql);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement