The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
[SOLVED] how i check if userid into touserarray or not
Hello ,
Code:
$check = $db->query_first("SELECT * FROM " . TABLE_PREFIX . " pmtext WHERE touserarray NOT IN ( 2,4,5 ) "); so how i ckeck about if this userid into this array or not ? i see already files of vb , and i found this fun unserialize() but i don't understand it ... |
#2
|
|||
|
|||
Yes, it's a serialized array. It may be possible to come up with a regular expression that would let you check using sql, but the easier way to do it would be to read all the records, use unserialize to make an array, then search the array. Unfortunately, you need to read all the rows from that table to do it that way.
Depending on what you're doing, you may want to use the pm table. Then you could do something like: Code:
$check = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "pmtext as pmtext LEFT JOIN ".TABLE_PREFIX."pm AS pm ON(pm.pmtextid=pmtext.pmtextid) WHERE pm.userid NOT IN ( 2,4,5 ) "); Edit again...also, I guess that will only work for finding users who haven't deleted the pm already. |
#3
|
||||
|
||||
Quote:
look that's Query don't make What I want to do . Let me explain it more ... i want make a code to sure that some moderators don't see any meassge to some users [Sending PM and PM receiving] , so i must check if These users-ids into touserarray or not . your Query is really a good idea , i did not think of it, despite its simplicity but result of this Query cannot exception for [receiving messages] to these users-ids . only exception for [sent messages] . i use regular expression before , but iam not good to used it Especially if [touserarray] contain more than User like that PHP Code:
|
#4
|
|||
|
|||
Hmm, I'm not sure I completely understand. But anyway, you could do something like this:
Code:
$msgs = $db->query_read_slave("SELECT * FROM " . TABLE_PREFIX . " pmtext"); while ($check = $db->fetch_array($msgs)) { if (($touser=@unserialize($check['touserarray'])) !== FALSE) { // check $touser[] } } |
Благодарность от: | ||
omardealo |
#5
|
||||
|
||||
Quote:
i get something , it's working good to get all user-id or usernames from touserarray and than you can make check Code:
global $db ,$vbulletin; $touser = array(); $sql = $db->query_read("SELECT touserarray FROM " . TABLE_PREFIX . "pmtext where pmtextid = 149"); while ($sql1 = $db->fetch_array($sql)) { $touser = unserialize($sql1['touserarray']); foreach($touser AS $key => $item) { if (is_array($item)) { foreach($item AS $subkey => $subitem) { $username = $subitem; $userid = $subkey; # store the data as $user_arr[$id] = $name $user_arr[$subkey] = $subitem; } } else { $username = $item; $userid = $key[$i]; $user_arr[$key[$i]] = $item; } # store the data as $user_arr[$id] = $name $user_arr[$userid] = $username; # or if you just want to print off the data during the loop... echo "ID: $userid; name: $username" . PHP_EOL; } // LOOP foreach ($user_arr as $k => $v) { // var to all user-id you can use&print it in templates $all_userid $all_userid .= $k . PHP_EOL; // OR you can print all user-id on this loop echo $k ; // OR you can user&print all user-id by array $all_userid[] = $k . PHP_EOL; } // print the array print_r ($all_userid); } your code is very simple ,I would like to used a small code but i don't understand this part Code:
if (($touser=@unserialize($check['touserarray'])) !== FALSE) { // check $touser[] } |
#6
|
|||
|
|||
I didn't look at all of your code, but I think my code is very simple because I left out all the things your code does! There probably isn't any way to make it smaller.
|
#7
|
||||
|
||||
okay but i still understand your code or how i used it
|
#8
|
||||
|
||||
Solution :
PHP Code:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|