vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   SQL-querie that forces users to switch skin (https://vborg.vbsupport.ru/showthread.php?t=106043)

Eagle Creek 01-22-2006 10:48 PM

SQL-querie that forces users to switch skin
 
Hi guys!

I want to run a MYSQL query that sets the default skin for ALL my users to ID 11 (for example).
After that they are still allowed to change later but I want to have all my current users, using a particular skin.

How can I do that?

harmor19 01-22-2006 10:59 PM

The only way is do a while loop.

PHP Code:

<?php
require_once('./global.php');

$getusers $db->query_read("SELECT * FROM " TABLE_PREFIX "user ");
while(
$user $db->fetch_array($getusers))
{
  
$db->query_write("UPDATE " TABLE_PREFIX "user
               SET styleid =  '11' "
);
}

?>

Test it on a test vbulletin first.

Eagle Creek 01-22-2006 11:13 PM

Quote:

Originally Posted by harmor19
a while loop

I don't really understand what that means..

But I am going to test your code out, thankyou!

Marco van Herwaarden 01-23-2006 11:31 AM

No need for any coding, just run the following query:
[sql]UPDATE user set styleid = 11;[/sql]

@harmor19

Do you have any idea what your code is doing? It will loop through each user registered on your board, then for each user it will set the styleid for all users.

This not only don't make sense, it will for sure bring your server on it's knees for some time if you have a big userbase.

harmor19 01-23-2006 12:01 PM

Well he wanted to set all his user styleid to "11" and that was the only way I knew how.

Eagle Creek 01-23-2006 12:14 PM

Quote:

Originally Posted by MarcoH64
No need for any coding, just run the following query:
[sql]UPDATE user set styleid = 11;[/sql]

@harmor19

Do you have any idea what your code is doing? It will loop through each user registered on your board, then for each user it will set the styleid for all users.

This not only don't make sense, it will for sure bring your server on it's knees for some time if you have a big userbase.


Thx!

Marco van Herwaarden 01-23-2006 12:28 PM

Quote:

Originally Posted by harmor19
Well he wanted to set all his user styleid to "11" and that was the only way I knew how.

If you really wanted to loop through each user individually (don't make sense), then you should have at least have limited the update query to the current userid:
PHP Code:

<?php 
require_once('./global.php'); 

$getusers $db->query_read("SELECT * FROM " TABLE_PREFIX "user "); 
while(
$user $db->fetch_array($getusers)) 

  
$db->query_write("UPDATE " TABLE_PREFIX "user 
               SET styleid = 11 WHERE userid = " 
$user['userid']); 


?>



All times are GMT. The time now is 11:14 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02450 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete