Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   MySQL Help (http://www.mysidiaadoptables.com/forum/showthread.php?t=5317)

Abronsyth 12-29-2016 09:31 AM

MySQL Help
 
I know the title is pretty vague but I am hoping someone can help me out here.

So the way the friends system works is it adds a user's id under the friend part in the database, but because users can have multiple friends it shows like "1, 16, 33" (for example). Clearly the comma is a separator, but I do not understand how new entries are added in that format or how the script knows to read each individual entry and use that information?

What I am trying to do is set up a system to record which users have used each promocode. So a user uses a promocode and it adds their ID to the list of those who've used it. Then I can add a setting option so that the admin can choose to make the promocode only redeemable once per user.

I can also eventually use it to set up a more stream-lined quest system than what I am currently using.

I found this chunk in class_friend.php which I think is relevant:
PHP Code:

   public function append($uid){
      
$mysidia Registry::get("mysidia");
      
$this->getfriendlist();
      
$friendsarray $this->friendlist->getids();      
      if(!
$this->isfriend$friendsarray[] = $uid;   
      
sort($friendsarray);     
      
$friends = (count($friendsarray) == 1)?$uid:implode(","$friendsarray);      
      
$mysidia->db->update("users", array("friends" => $friends), "username='{$this->user->username}'");
   } 

But I am having a hard time figuring this out :littlecfrown: Here's what I've added to class_promocode.php so far;
PHP Code:

  private function checkredeem() {
      
//This will check to see which users have already redeemed this code.
      
$mysidia Registry::get("mysidia");
      
$redeemed $mysidia->db->select("promocodes", array("redeemed"), "pid='{$this->pid}'")->fetchColumn();
      
$redeem = {$mysidia->user->uid};
      if(empty(
$this->redeemable)) return TRUE;
      else{
        if(
$redeemed){throw new AlreadyRedeemedException($mysidia->lang->redeemed);}
        
//Need to work on this part still...need to make it so that when they redeem it, they're ID is added to the list so they can't redeem it again
        
else {$mysidia->db->update("promocodes", array("redeemed" => $redeem), "pid='{$this->pid}'");}
        return 
TRUE;
      }
  } 

(I have lang_promo, admincp/promo, and admincp/view/promoview all ready to go, as soon as I get this figured out I'll release it as an actual mod)

But this is all I've got and right now it's pretty useless until I figure out how to properly add uids to the database.

If someone could help me I would really, really appreciate it <3


All times are GMT -5. The time now is 07:47 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.