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)
-   -   Use Owned_Adoptable to call Adoptable? (http://www.mysidiaadoptables.com/forum/showthread.php?t=5436)

aquapyrofan 05-04-2017 02:33 PM

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?

Dinocanid 05-04-2017 05:35 PM

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)

aquapyrofan 05-04-2017 06:13 PM

Quote:

Originally Posted by Dinocanid (Post 36293)
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.

Dinocanid 05-04-2017 06:48 PM

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?

KatFennec 05-04-2017 06:54 PM

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.

Dinocanid 05-04-2017 07:25 PM

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..."));

KatFennec 05-04-2017 07:36 PM

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?

Dinocanid 05-04-2017 07:49 PM

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.

KatFennec 05-04-2017 08:44 PM

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.


All times are GMT -5. The time now is 01:38 PM.

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