View Single Post
  #58  
Old 04-09-2012, 10:09 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 592,371
Hall of Famer is on a distinguished road
Default

The code should look like this:

PHP Code:
$pet $adopts->join("adoptables""adoptables.type = owned_adoptables.type")->select("owned_adoptables", array(), constant("PREFIX")."owned_adoptables.aid = '{$aid}'")->fetchObject(); 
The script means that you are joining tables adoptables and owned_adoptables by referencing the field 'type', which is supposed to be the same for each row fetched from database. The new script allows you to chain class methods by fetching object or array directly after a select query is used, so you do not need to write separate lines for mysql select codes. After applying the codes above, all you have to do is to retrieve the properties such as:

PHP Code:
$pet->id //The adoptables species id from table prefix.adoptables
$pet->description // The adoptables species description from table prefix.adoptables
$pet->currentlevel // The adoptables currentlevel from table prefix.owned_adoptables
$pet->totalclicks // The adoptables totalclicks from table prefix.owned_adoptables 
If you want to join another table, just use the join() method twice in the script and chain them with select() and fetchObject() methods, it will work out nicely too.

And btw the script now wont autoban your user unless they try to adopt pets that have been taken away from pound center one day ago or earlier. In future I may improve this performance by allowing admins to determine how long this 'session' is going to be. Of course if you have a user trying to adopt a pet that has been adopted one day ago, he/she is most likely a cheater/hacker using inspect element(unless he/she takes a day to adopt a pound pet, which is stupid I say?). XD
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.