A way to exclude pets from daycare?

Forum
Last Post
Threads / Messages

Infernette

CODE CODE CODE CODE CODE
Member
Joined
Jan 29, 2013
Messages
164
Points
0
Location
Where I live? I live home.
Mysidian Dollar
15,625
I was wondering if there was a way to exclude pets from the daycare once clicked for the day, I know there is ways to tell if the pet is clicked but I don't know how to exclude it from the query.
 
Maybe you have to add a "wasClicked" attribute to the tables? I did this little crappy code down here, I'm pretty sure it has bugs and maybe it's not the best solution (when I ask for a sizeof of the array it outputs 34 instead of 33, so it's doing extra stuff :D), but hey it's a start... right?

I don't know the documentation of this project, what the functions do etc... I'm pretty new xDWe have to try to find out where to restrict addition of adoptables to the daycare. That's the getConditions() function.
The basic idea was to take the IDs that have been clicked and compare the adoptable id to them. This condition is saved in the $conditions variable that will be used when selecting adoptables from owned_adoptables in the function above getConditions() (I believe it's getAdopts()).

In the class_daycare, getConditions(), before returning:

PHP:
  	$date = new DateTime;
           	$datetime = $date->format('Y-m-d');
            	$user = $mysidia->user;
            	
//take adoptable IDs that have been clicked by the user in today's date
		$idsM = $mysidia->db->select("vote_voters", array("adoptableid"), "date='{$datetime}' and username='{$user->username}'")->fetchAll(PDO::FETCH_COLUMN);
		$adoptsIDs = new ArrayObject($idsM);
		
//append to the conditions string an aid restrictions (aid can't be equal to the IDs in idsM) - yes, for each adoptable it has to compare its ID to all of the IDs ._.
		for($index = 0; $index < sizeof($adoptsIDs); $index++)
		{
			//echo $datetime;
			$conditions .= " and aid != '{$adoptsIDs[$index]}'";
		}

I only tested it twice with two different users... It seems to work with today's date, but when using writing down a specific date (yesterday's date) it returned 34 instead of 33, so I don't know what it's doing as an extra? This is not a good solution, but maybe it will help you somehow :/ edit: hm, I counted wrong... Apparently everything's fine(?), but still it's not an optimal solution (the amount of comparisons it has to do...) And it only works if you refresh the page, so it won't take out an egg from the daycare when it's clicked of course, it updates the array after refresh

I also tried to restrict their appearance (in levelup, in daycare() function) instead of restricting addition, but I don't really know how the page is set up so it was errors after errors.
 
Last edited:
That works perfectly! Refeshing is what I meant, and it seems to flow nicely (I also have an upgraded server package so yeah, dunno how well it'd work for free hosters. XD)
 
I love your site so Glad I could help! I really don't know another way other than comparing IDs, but the increasing number of IDs worries me xD Constructing another table not_clicked and selecting from owned_adoptables MINUS selecting from vote_voters, but I really don't know how to work with the date there xD But if it works I'm glad I could help ^^
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,134
Members
1,604
Latest member
grandcorsair
BETA

Latest Threads

Top