vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Product Install Code - Adding a row for each row in user (https://vborg.vbsupport.ru/showthread.php?t=107381)

Nullifi3d 02-07-2006 03:40 PM

Product Install Code - Adding a row for each row in user
 
Upon product install I need to add a row to a mysql table for each row that is in the table 'user'. How would I do this bring the userid and username intot he new table? I think it's something like this:
Code:

        $vbuser =& $vbulletin->userinfo;
                foreach ($vbuser AS $userid => $userid, $username => $username,) {
                $db->query_write("INSERT INTO " . TABLE_PREFIX . "banners (
                userid, username, title, url, link, ext, width, height, clicks, available, impressions, status
                ) VALUES (
                '$userid', '$username', '', '', '', '', '', '', 0, '{$vbulletin->options['banner_impressions_join']}', 0, ''
                )");
    }

I know that $vbulletin->userinfo contains info for the user visiting the page, so it would not work. What do I need to do to make this work?

Andreas 02-07-2006 03:51 PM

Untested, but should work (if I havn't added a typo or smth.)

PHP Code:

$db->query_write("
    INSERT INTO " 
TABLE_PREFIX "banners
    (userid, username, title, url, link, ext, width, height, clicks, available, impressions, status)    
    (SELECT user.userid, user.username, '' AS title, '' AS url, '' AS link, '' AS ext, 0 As width, 0 AS height, 0 AS clicks, 0 AS available, 0 AS status)
    FROM " 
TABLE_PREFIX "user AS user)
"
); 


Nullifi3d 02-07-2006 03:58 PM

Ahh, suprised I didn't think of that for the query, but will that add a row every user in the table 'user' when the product is installed? What if there is 300 users in the table? it looks like this will only add 1 row.

Andreas 02-07-2006 04:05 PM

It should add rows for all users.

Nullifi3d 02-07-2006 04:10 PM

Thank you it did work.


All times are GMT. The time now is 03:32 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.01609 seconds
  • Memory Usage 1,715KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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