![]() |
Select value from table where varname = '3 different things''
I am trying to select 3 items from the setting table:
the info from the value column where the varname column equals illegalusernames, minusernamelength & maxusernamelength. Something like: Code:
"SELECT value AS illegalusernames FROM ".TABLE_PREFIX."setting WHERE varname = 'illegalusernames'" |
Your where would be something like:
Code:
SELECT value, varname FROM `setting` WHERE varname IN ('illegalusernames','minusernamelength ','maxusernamelength') |
For some odd reason the sql only fetches the illegalusernames field when I read the var_dump output.
Code:
$results = $db->query_first("SELECT value, varname FROM ".TABLE_PREFIX."setting WHERE varname IN ('illegalusernames','minuserlength ','maxuserlength')"); |
(The same was true when I tested it on my setting table but then I went and looked and neither of those other settings are in there.) However, if the rows are in your table, you aren't going to get them by using query_first. query_first only fetches a single row. You need to do a regular query and then a fetch_array (probably in a while loop to grab the values).
|
I was doing some research and found matching information to what you're saying and tried adjusting my code:
Code:
$query = $db->query_read("SELECT value, varname FROM ".TABLE_PREFIX."setting WHERE varname IN ('illegalusernames','minuserlength ','maxuserlength')"); Strange enough, when executing this sql straight into phpmyadmin it returns all three rows. So I assume it must be something with how I am calling the db queries within vbulletin/php. I have tried several variations of queries/fetches with no success. |
You want to do something like:
Code:
$query = $db->query_read("SELECT value, varname FROM ".TABLE_PREFIX."setting WHERE varname IN ('illegalusernames','minuserlength ','maxuserlength')"); Edit: Oops, just noticed that Lynne beat me to that first reply. Anyway, you also have an extra space in the 'minuserlength' string. |
Quote:
|
All times are GMT. The time now is 12:00 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|