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 04-15-2012, 11:11 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 85,103
SilverDragonTears is on a distinguished road
Default Where clause

How do I do a where clause for this if I only want adopts that have the value 'shop' for the field whenisavail to show up?

Code:
$stmt = $adopts->join("adoptables_conditions", "adoptables_conditions.id = adoptables.id")
				   ->select("adoptables", array());
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 04-16-2012, 12:34 AM
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: 397,227
Hall of Famer is on a distinguished road
Default

Its quite easy, do this:

PHP Code:
$stmt $adopts->join("adoptables_conditions""adoptables_conditions.id = adoptables.id")                    ->select("adoptables", array(), "whenisavail = 'shop'"); 
The select() method accepts three arguments: table, columns and whereclause. The table is quite obvious, while columns need to be an array of what columns you want to fetch(pass an empty array to fetch all columns). The whereclause is whatever is after the WHERE keyword in an sql statement.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 04-16-2012, 12:39 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 85,103
SilverDragonTears is on a distinguished road
Default

See, I tried that before I posted and I got this:

Code:
Fatal error: Uncaught exception 'Exception' with message 'Database error 1052 - Column 'whenisavail' in where clause is ambiguous' in /home/taleofdr/public_html/classes/class_database.php:161 Stack trace: #0 /home/taleofdr/public_html/classes/class_database.php(81): Database->_query('adoptables', Array, 'select', 'whenisavail = '...') #1 /home/taleofdr/public_html/dshop.php(25): Database->select('adoptables', Array, 'whenisavail = '...') #2 {main} thrown in /home/taleofdr/public_html/classes/class_database.php on line 161
__________________

Check out SilvaTales
Reply With Quote
  #4  
Old 04-16-2012, 12:43 AM
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: 397,227
Hall of Famer is on a distinguished road
Default

Oh I see, this is because whenisavail field is present in both columns. The trick here is:

PHP Code:
$stmt $adopts->join("adoptables_conditions""adoptables_conditions.id = adoptables.id")
               ->
select("adoptables", array(), constant(PREFIX)."adoptables.whenisavail = 'shop'"); 
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 04-16-2012, 12:45 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 85,103
SilverDragonTears is on a distinguished road
Default

Warning: constant() [function.constant]: Couldn't find constant adopts_ in /home/taleofdr/public_html/dshop.php on line 26

Fatal error: Uncaught exception 'Exception' with message 'Database error 1054 - Unknown column 'adoptables.whenisavail' in 'where clause'' in /home/taleofdr/public_html/classes/class_database.php:161 Stack trace: #0 /home/taleofdr/public_html/classes/class_database.php(81): Database->_query('adoptables', Array, 'select', 'adoptables.when...') #1 /home/taleofdr/public_html/dshop.php(26): Database->select('adoptables', Array, 'adoptables.when...') #2 {main} thrown in /home/taleofdr/public_html/classes/class_database.php on line 161
__________________

Check out SilvaTales
Reply With Quote
  #6  
Old 04-16-2012, 12:49 AM
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: 397,227
Hall of Famer is on a distinguished road
Default

Oh my, forgot to enclose PREFIX by double quote. The below code should work:

PHP Code:
 $stmt $adopts->join("adoptables_conditions""adoptables_conditions.id = adoptables.id")
               ->
select("adoptables", array(), constant("PREFIX")."adoptables.whenisavail = 'shop'"); 
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #7  
Old 04-16-2012, 12:52 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 85,103
SilverDragonTears is on a distinguished road
Default

What in the world? The one adopt I have to test it isn't showing up :/
__________________

Check out SilvaTales
Reply With Quote
  #8  
Old 04-16-2012, 12:58 AM
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: 397,227
Hall of Famer is on a distinguished road
Default

umm you are trying to add a new condition called 'Shop'? Id say look into the functions_adopts.php and see if you can find any clues. As it is now the adoptables conditions are hard-coded, which means creating your own is not easy. You have to modify the core script.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #9  
Old 04-16-2012, 01:02 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 85,103
SilverDragonTears is on a distinguished road
Default

No I just named it that so I could differentiate it from the others.
__________________

Check out SilvaTales
Reply With Quote
  #10  
Old 04-16-2012, 01:11 AM
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: 397,227
Hall of Famer is on a distinguished road
Default

umm thats weird, the adoptables should show up then. First check your database to see if the field 'whenisavail' indeed has the value 'shop', and then see if the adoptable ids are the same for this pet in table prefix.adoptables and prefix.adoptables_conditions. Gloometh and Iris both had problems with the pets id being different in the two tables, and for this reason the adoptables wont show.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
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 10:18 AM.

Currently Active Users: 944 (0 members and 944 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