#1
|
||||
|
||||
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()); |
#2
|
||||
|
||||
Its quite easy, do this:
PHP Code:
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#3
|
||||
|
||||
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 |
#4
|
||||
|
||||
Oh I see, this is because whenisavail field is present in both columns. The trick here is:
PHP Code:
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#5
|
||||
|
||||
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 |
#6
|
||||
|
||||
Oh my, forgot to enclose PREFIX by double quote. The below code should work:
PHP Code:
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#7
|
||||
|
||||
What in the world? The one adopt I have to test it isn't showing up :/
|
#8
|
||||
|
||||
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. |
#9
|
||||
|
||||
No I just named it that so I could differentiate it from the others.
|
#10
|
||||
|
||||
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. |
|
|
What's New? |
What's Hot? |
What's Popular? |