Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database{
- var $db_link;
- function __construct(){
- echo "Initializing database...<br/>";
- $this->db_link = $this->plugIn();
- }
- function plugIn(){
- echo "Plugging in...<br/>";
- $db_host = "";
- $db_name = "";
- $db_user = "";
- $db_pass = "";
- $db_link = mysql_connect($db_host,$db_user,$db_pass );
- if(!$db_link){
- die("No donuts for yu.");
- }else{
- $the_db = mysql_select_db($db_name,$db_link);
- if(!$the_db){
- die("No db for yu.");
- }else{
- echo "Got the database...<br/>";
- return $db_link;
- }
- }
- }
- function getFlag($activity_token){
- echo "Getting table...<br/>";
- $result = mysql_query("SELECT activity_flag FROM activities WHERE activity_token = '$activity_token'",$this->db_link);
- $num_rows = mysql_num_rows($result);
- if($num_rows == 0){
- return false;
- }else{
- return mysql_fetch_object($result)->activity_flag;
- }
- }
- function fetchActivityStatus($activity_token){
- echo "Fetching flag status...<br/>";
- $the_flag = $this->getFlag($activity_token);
- if(!$the_flag){
- return "empty";
- }else{
- return $the_flag;
- }
- }
- function putActivity($activity_token){
- $instruction = "INSERT INTO activities(activity_token,activity_flag) VALUES('$activity_token','pending')";
- if(!mysql_query($instruction,$this->db_link)){
- return false;
- }else{
- return true;
- }
- }
- function updateActivityFlag($activity_token, $new_flag){
- echo "Updating flag...<br/>";
- $query = "UPDATE activities SET activity_flag='$new_flag' WHERE activity_token = '$activity_token'";
- if(!mysql_query($query,$this->db_link)){
- return false;
- }else{
- return true;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement