MySQL Help

Forum
Last Post
Threads / Messages

Abronsyth

A Headache Embodied
Member
Joined
Aug 25, 2011
Messages
1,012
Points
36
Location
NY
Mysidian Dollar
73,285
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:
   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:
  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
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top