127 lines
3.0 KiB
PHP
127 lines
3.0 KiB
PHP
|
<?php
|
||
|
//include('foto.php');
|
||
|
|
||
|
class Community extends Database{
|
||
|
|
||
|
function __construct(){
|
||
|
$this->connect();
|
||
|
}
|
||
|
///community
|
||
|
//create
|
||
|
function create($data){
|
||
|
//INSERT INTO community VALUES()
|
||
|
$rows = 'name,type,createdBy,description';
|
||
|
$value = array( $data['name'],
|
||
|
$data['type'],
|
||
|
$data['user'],
|
||
|
$data['desc']
|
||
|
);
|
||
|
if ($this->insert('community',$value,$rows))return true;
|
||
|
else return false;
|
||
|
}
|
||
|
//update
|
||
|
function inputPhotoComm($foto,$id){
|
||
|
$where = "id='".$id."'" ;
|
||
|
echo $where;
|
||
|
$rows = array( 'photo' => $foto
|
||
|
);
|
||
|
if ($this->update('community',$rows,$where))return true;
|
||
|
else return false;
|
||
|
}
|
||
|
//update
|
||
|
function updateComm($data){
|
||
|
//UPDATE community SET column1=value,... WHERE id_community=''
|
||
|
$rows = array( 'name' => $data['name'],
|
||
|
'description' => $data['desc'],
|
||
|
'photo' => $data['photo']
|
||
|
);
|
||
|
$where = 'id = '.$data['id'];
|
||
|
if ($this->update('community',$rows,$where)) return true;
|
||
|
else return false;
|
||
|
}
|
||
|
//read
|
||
|
function getComDesc($id){
|
||
|
//SELECT * FROM community WHERE id=''
|
||
|
$where = 'id='.$id;
|
||
|
if ($this->select('community','*',$where)){
|
||
|
return $this->getResult();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
///member
|
||
|
//create
|
||
|
function inputMember($data){
|
||
|
//INSERT INTO member VALUES()
|
||
|
$rows = 'username,id_community,role';
|
||
|
$value = array( $data['user'],
|
||
|
$data['id_community'],
|
||
|
$data['role']
|
||
|
);
|
||
|
if ($this->insert('member',$value,$rows)) return true;
|
||
|
else return false;
|
||
|
}
|
||
|
//read
|
||
|
function getComMember($id){
|
||
|
//SELECT username FROM member WHERE id_community=''
|
||
|
$where = 'member.id_community='.$id.' and member.username=profile.username';
|
||
|
if ($this->select('member,profile','*',$where)){
|
||
|
return $this->getQueryResult();
|
||
|
}
|
||
|
}
|
||
|
//read
|
||
|
function ismember($idp,$idc){
|
||
|
$where = "username='".$idp."' and id_community='".$idc."'";
|
||
|
if ($this->select('member','*',$where)){
|
||
|
$result = $this->getQueryResult();
|
||
|
if (mysql_num_rows($result)==1) return true;
|
||
|
else return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
///activities
|
||
|
//create
|
||
|
function createEvent($data){
|
||
|
//INSERT INTO activities VALUES()
|
||
|
$rows = 'name,type,desciption,date,community';
|
||
|
$value = array( $data['name'],
|
||
|
$data['type'],
|
||
|
$data['desc'],
|
||
|
$data['date'],
|
||
|
$data['community']
|
||
|
);
|
||
|
if ($this->insert('activities',$value,$rows)) return true;
|
||
|
else return false;
|
||
|
}
|
||
|
|
||
|
//update
|
||
|
function inputPhotoEve($foto,$id){
|
||
|
$where = "id='".$id."'" ;
|
||
|
echo $where;
|
||
|
$rows = array( 'poster' => $foto
|
||
|
);
|
||
|
if ($this->update('activities',$rows,$where))return true;
|
||
|
else return false;
|
||
|
}
|
||
|
|
||
|
//update
|
||
|
function updateEvent($data){
|
||
|
//UPDATE activities SET column1=value,... WHERE id_event=''
|
||
|
}
|
||
|
//read
|
||
|
function getEvent($id){
|
||
|
//SELECT * FROM activities WHERE community=''
|
||
|
$where = 'community='.$id;
|
||
|
if ($this->select('activities','*',$where)){
|
||
|
return $this->getQueryResult();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getEvent2($id){
|
||
|
//SELECT * FROM activities WHERE community=''
|
||
|
$where = 'id='.$id;
|
||
|
if ($this->select('activities','*',$where)){
|
||
|
return $this->getResult();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
?>
|