This repository has been archived by the owner on Mar 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
lib.php
56 lines (55 loc) · 1.69 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
function getInfoUser($nama){
$sql="SELECT * FROM user u left join tweet t on u.lasttweet=t.id where u.username='$nama'";
$hasil=query($sql);
return $hasil;
}
function getJmlTweet($nama){
$sql="SELECT count(*) jml FROM tweet where username='$nama'";
$hasil=query($sql);
$hasil=$hasil[0];
return $hasil['jml'];
}
function cekUsername($nama){
$sql="SELECT username FROM user WHERE username='$nama'";
$hasil=query($sql);
return (count($hasil)==1);
}
function getArrayFollowing($nama){
$temp=array();
$tempImg=array();
$temp2=array();
$sql="SELECT f.userb,u.image FROM follow f,user u where f.userb=u.username and f.usera='$nama'";
$hasil=query($sql);
foreach($hasil as $item){
$temp[]=$item['userb'];
$tempImg[$item['userb']]=$item['image'];
}
$temp2['nama']=$temp;
$temp2['image']=$tempImg;
return $temp2;
}
function getArrayFollower($nama){
$temp=array();
$tempImg=array();
$temp2=array();
$sql="SELECT f.usera,u.image FROM follow f,user u where f.usera=u.username and f.userb='$nama'";
$hasil=query($sql);
foreach($hasil as $item){
$temp[]=$item['usera'];
$tempImg[$item['usera']]=$item['image'];
}
$temp2['nama']=$temp;
$temp2['image']=$tempImg;
return $temp2;
}
function getTweetById($id){
$sql="SELECT * FROM tweet where id=$id";
$hasil=query($sql);
return $hasil[0];
}
function getTweetsByUser($nama){
$sql="SELECT tw.id,tw.username,DATE_FORMAT(tw.tglwaktu,'%h:%i %p, %e %b %Y') tgl,tw.isi,u.image FROM tweet tw, user u where u.username=tw.username and tw.username='$nama' ORDER BY tglwaktu DESC LIMIT 10";
$hasil=query($sql);
return $hasil;
}