The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
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'" "SELECT value AS minusernamelength FROM ".TABLE_PREFIX."setting WHERE varname = 'minusernamelength'" "SELECT value AS maxusernamelength FROM ".TABLE_PREFIX."setting WHERE varname = 'maxusernamelength'" |
|
#2
|
||||
|
||||
|
Your where would be something like:
Code:
SELECT value, varname FROM `setting` WHERE varname IN ('illegalusernames','minusernamelength ','maxusernamelength')
|
| Благодарность от: | ||
| Nullifi3d | ||
|
#3
|
|||
|
|||
|
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')");
|
|
#4
|
||||
|
||||
|
(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).
|
|
#5
|
|||
|
|||
|
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')");
$results = $db->fetch_array($query);
print_r($results);
The Above Outputs:
Array ( [value] => admin moderator op9 option9 option.9 forum vbulletin [varname] => illegalusernames )
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. |
|
#6
|
|||
|
|||
|
You want to do something like:
Code:
$query = $db->query_read("SELECT value, varname FROM ".TABLE_PREFIX."setting WHERE varname IN ('illegalusernames','minuserlength ','maxuserlength')");
while ($results = $db->fetch_array($query))
{
print_r($results);
}
Edit: Oops, just noticed that Lynne beat me to that first reply. Anyway, you also have an extra space in the 'minuserlength' string. |
|
#7
|
|||
|
|||
|
Quote:
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|