Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2017, 02:33 PM
aquapyrofan aquapyrofan is offline
Member
 
Join Date: Apr 2017
Posts: 48
Gender: Unknown/Other
Credits: 8,429
aquapyrofan is on a distinguished road
Question Use Owned_Adoptable to call Adoptable?

For my site, I'm tying a lot of traits to species (prefix_adoptable) rather than to individual pets (prefix_owned_adoptable). Problem is, for things like profiles and items, I need to be able to get those values for the pet's species, using the pet's information. How do I call the other table?
Reply With Quote
  #2  
Old 05-04-2017, 05:35 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 65,180
Dinocanid is on a distinguished road
Default

To call data from the adoptables table (or any table), you would just use a line of code likes this:

HTML Code:
$mysidia->db->select("adoptable", array("Column"), "Row = '$somevalue'")->fetchColumn();
With "adoptable" being the table name. It is case-sensitive though, so it must be exactly how it is typed in phpMyAdmin. Just change adoptable to owned_adoptables if you want that table.

If you're trying to define a variable or something, it would look like this:
HTML Code:
$trait = $mysidia->db->select("adoptable", array("Column"), "Row = '$somevalue'")->fetchColumn();
Then you can just use $trait to call it in the php file whenever you need it, instead of calling the table every time. (replacing trait with whatever you would call it of course)
__________________
Reply With Quote
  #3  
Old 05-04-2017, 06:13 PM
aquapyrofan aquapyrofan is offline
Member
 
Join Date: Apr 2017
Posts: 48
Gender: Unknown/Other
Credits: 8,429
aquapyrofan is on a distinguished road
Default

Quote:
Originally Posted by Dinocanid View Post
To call data from the adoptables table (or any table), you would just use a line of code likes this:

HTML Code:
$mysidia->db->select("adoptable", array("Column"), "Row = '$somevalue'")->fetchColumn();
With "adoptable" being the table name. It is case-sensitive though, so it must be exactly how it is typed in phpMyAdmin. Just change adoptable to owned_adoptables if you want that table.

If you're trying to define a variable or something, it would look like this:
HTML Code:
$trait = $mysidia->db->select("adoptable", array("Column"), "Row = '$somevalue'")->fetchColumn();
Then you can just use $trait to call it in the php file whenever you need it, instead of calling the table every time. (replacing trait with whatever you would call it of course)
Is this how I'd use the owned_adoptables "type" value to call a value in adoptables? I'm confused because it doesn't seem like it.
Reply With Quote
  #4  
Old 05-04-2017, 06:48 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 65,180
Dinocanid is on a distinguished road
Default

I can't understand you're question too well, so I probably gave you the wrong code just now, sorry ^^;
Are you trying to get the species of a user's pet and use that to fetch the traits?
__________________
Reply With Quote
  #5  
Old 05-04-2017, 06:54 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 7,841
KatFennec is on a distinguished road
Default

Taking over for aqua here, since I'm the one who does most of the code work for our site. And yes, that's exactly what we were trying to do.
__________________
Reply With Quote
  #6  
Old 05-04-2017, 07:25 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 65,180
Dinocanid is on a distinguished road
Default

Oh! Okay, then you would first get the species of the user's adopt with this:
Quote:
$aid = $this->getField("aid")->getValue();
$adopt = new OwnedAdoptable($aid);
$type = $adopt->getType();
If you're using the manage function in myadoptsview.php. Then from there it depends on how the traits are stored. If they have their own separate columns in the database then you could do something like:
Quote:
if($type = "insertspecieshere"){
$trait1 = $mysidia->db->select("adoptables", array("yourtrait"), "type = '{$type}'")->fetchColumn();
}
This is assuming that, in the prefix_adoptables table, each trait is a seperate column and not all bunched into one column. Then, depending on the species, the first trait will be changed accordingly. Then to show the trait to the user you could do this:
Quote:
$document->add(new Comment("Traits: {$trait1}, {$trait2}, etc..."));
__________________
Reply With Quote
  #7  
Old 05-04-2017, 07:36 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 7,841
KatFennec is on a distinguished road
Default

Alright, and I'm going to need to use db referrals instead of getWhatever, if I need to use these in an item function, yeah?
__________________
Reply With Quote
  #8  
Old 05-04-2017, 07:49 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 65,180
Dinocanid is on a distinguished road
Default

To get a pet's info from the database, you would need to get the ID of the pet somehow. In the case of items, items get the ID of a pet like this:
Quote:
$adopt->aid
in functions_items.php. (Which is where you define what a certain item does)
I haven't tried, but I'm assuming $adopt->getType(); or $adopt->getType would still work. This is because items already call the pet that it's about to be used on so you don't have to use the whole database call to get it. From there, the code should still work the same.
__________________
Reply With Quote
  #9  
Old 05-04-2017, 08:44 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 7,841
KatFennec is on a distinguished road
Default

Unfortunately, the getFoo() functions don't seem to work in that file - I had it error out frequently when I tried, complaining of invalid something. The alternative seems to be manually calling it, but I think I can get it working. I'll swing back and let you know if it does.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:46 AM.

Currently Active Users: 9647 (0 members and 9647 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636